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

后端 未结 7 1539
难免孤独
难免孤独 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 10:47

    Using splice seems to be the easiest and cleanest way to me:

    open FILE, "<$ARGV[0]";
    my @file = ;
    splice(@file, 0, 1);
    

    Done. Now your @file array doesn't have the first line anymore.

提交回复
热议问题