in reply to extract last 1 min log and find a string
Some alternatives without using File::ReadBackwards:
#!/usr/bin/env perl # $Id: reverse.pl,v 1.2 2017/07/20 18:51:47 karl Exp karl $ # http://perlmonks.org/?node_id=1195633 use strict; use warnings; use Tie::File; my $file = shift; print qx(cat $file); print qq(--\n); open my $fh, '<', $file or die $!; my @data = reverse <$fh>; close $fh; print for @data; print qq(--\n); tie( @data, "Tie::File", $file, mode => 0 ) or die $!; for ( reverse( 0 .. $#data ) ) { print qq($data[$_]\n); } untie @data; __END__ karls-mac-mini:monks karl$ ./reverse.pl file.txt foo bar nose cuke -- cuke nose bar foo -- cuke nose bar foo
What you choose may depend on the size of your file. And everything has it's price.
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
|
|---|