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

后端 未结 11 1949
夕颜
夕颜 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:17

    Without relying on tail, which I probably would do, if you have more than $FILESIZE [2GB?] of memory then I'd just be lazy and do:

    my @lines = <>;
    my @lastKlines = @lines[-1000,-1];
    

    Though the other answers involving tail or seek() are pretty much the way to go on this.

提交回复
热议问题