Perl - how to skip a line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SANDY1722
    New Member
    • Sep 2007
    • 6

    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...
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by SANDY1722
    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

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Code:
      open(FH,"yourfile") or die "$!";
      readline(FH); #<-- read the first line effectively skipping it
      while(<FH>){
         print $_;
      }

      Comment

      • SANDY1722
        New Member
        • Sep 2007
        • 6

        #4
        Originally posted by numberwhun
        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

        Comment

        Working...