473,480 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Perl - how to skip a line

6 New Member
Hi,

I am new to perl. I want to open a flle with some data and skip the fisrt line, and write to another file.

Source File: source.txt

Data: Bank Acct - Cheking
Balance: $230
Customer: Tom
-------
------

Target File should only contain all the lines, except the first one

target: target.txt

Data: Balance: $230
Customer: Tom
-------
------

Thanks for help on this...
Sep 21 '07 #1
3 12715
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi,

I am new to perl. I want to open a flle with some data and skip the fisrt line, and write to another file.

Source File: source.txt

Data: Bank Acct - Cheking
Balance: $230
Customer: Tom
-------
------

Target File should only contain all the lines, except the first one

target: target.txt

Data: Balance: $230
Customer: Tom
-------
------

Thanks for help on this...
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

Please post all questions to the Perl Forum in the future!


- MODERATOR
Sep 21 '07 #2
KevinADC
4,059 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. open(FH,"yourfile") or die "$!";
  2. readline(FH); #<-- read the first line effectively skipping it
  3. while(<FH>){
  4.    print $_;
  5. }
Sep 21 '07 #3
SANDY1722
6 New Member
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

Please post all questions to the Perl Forum in the future!


- MODERATOR

------------------------------------------------------

Thanks a lot
Sep 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3388
by: Caj Zell | last post by:
Hello, I am looking a little bit at python and am curious of one thing I often use in perl. Suppose, I want to change the string "best_composer" to "Zappa" in a document called facts.txt, then...
4
2443
by: Tom Allison | last post by:
I'm stuck on something stupid. I'm trying to use perl to open up a database handle and I can't find the right database dsn string. my $data_source = "dbi:Pg:mydatabase"; my $username =...
8
1819
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On the third line I keep getting this message when I go to run this. This is just the first part of the code. Please any advice...
1
1284
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On thef fourth line I keep getting this message when I go to run this. . Please any advice would help.I am using TextPad, and window...
6
4378
by: jimwest1995 | last post by:
Hi! I have a text file with 60 lines in it and I need to skip to line 51 to begin processing. In VB6 there was .SkipLine but I don't see that function in VB.Net. Any suggestions on how to do this?...
2
2432
by: ogo796 | last post by:
hi all i am having a problem with reading the lines from the text file my file look like this: #"11-02-2008 " chief vs tumi "1234" "12-02-2008 " duma vs duma "1254" i am wondering if the...
13
25743
by: youngjin.michael | last post by:
Hello, I am new to Python and have one simple question to which I cannot find a satisfactory solution. I want to read text line-by-line from a text file, but want to ignore only the first line....
10
1979
by: babno | last post by:
The console freezes and I get this error message when I search the array is loaded in from a file. the interesting thing though, is the error only comes up if the search is there. if it isn't...
3
1923
by: ulnanewbie | last post by:
Can some one help me to understand the below perl code line: 1. my @myarray; 2. $myarray {testscore} =0; 3. $myarray {testgrade} = "none"; I understand the code line #1, it is basically...
1
5802
by: santhanalakshmi | last post by:
Hi, In Windows 2003, i installed the Active Perl. When i log into this system, i am facing this error "Perl command line interpreter encountered a problem and needed to close" Error...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.