How can I read lines from the end of file in Perl?

后端 未结 11 1935
夕颜
夕颜 2020-12-06 02:41

I am working on a Perl script to read CSV file and do some calculations. CSV file has only two columns, something like below.

One Two
1.00 44.000
3.00 55.000         


        
11条回答
  •  不思量自难忘°
    2020-12-06 03:09

    The modules are the way to go. However, sometimes you may be writing a piece of code that you want to run on a variety of machines that may be missing the more obscure CPAN modules. In that case why not just 'tail' and dump the output to a temp file from within Perl?

    #!/usr/bin/perl
    
    `tail --lines=1000 /path/myfile.txt > tempfile.txt`
    

    You then have something that isn't dependent on a CPAN module if installing one may present an issue.

提交回复
热议问题