Best way to skip a header when reading in from a text file in Perl?

后端 未结 7 1541
难免孤独
难免孤独 2021-02-01 10:16

I\'m grabbing a few columns from a tab delineated file in Perl. The first line of the file is completely different from the other lines, so I\'d like to skip that line as fast a

相关标签:
7条回答
  • 2021-02-01 11:07

    You can just assign it a dummy variable for the 1st time:

    #!/usr/bin/perl
    use strict;
    use warnings;
    
    open my $fh, '<','a.txt' or die $!;
    
    my $dummy=<$fh>;   #First line is read here
    while(<$fh>){
            print ;
    }
    close($fh);
    
    0 讨论(0)
提交回复
热议问题