469,352 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Perl - how to skip a line

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 12270
numberwhun
3,503 Expert Mod 2GB
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 Expert 2GB
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
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

Post your reply

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

Similar topics

3 posts views Thread by Caj Zell | last post: by
4 posts views Thread by Tom Allison | last post: by
8 posts views Thread by gooop | last post: by
2 posts views Thread by ogo796 | last post: by
10 posts views Thread by babno | last post: by
3 posts views Thread by ulnanewbie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.