I guess this is general Perl question. I want to display the last 50 lines of log file. I found few examples, showing read entire file to an array and take the last 50 lines. But if log file is too big, I guess this may not be a good choice. Anybody has suggestions? Thanks Sri
Want to display the last 50 lines ... but where? On screen or in a file? Please be more elaborate about the requirement.Still, to display on screen...the command "tail -50f {filename}" can be used.
#!/path/to/perluse strict;use warnings;my $max_lines = shift;my @buffer;while(<STDIN>){ push(@buffer, $_); shift(@buffer) if (@buffer > $max_lines);}print foreach(@buffer);
Thanks fish, nice input to me. It is very help full. Like C(seek, I guess), we can't able to go directly to the end of file and come back.