This can't be correct. You never create an array with 100 lines. You do create 100 arrays with one line each, using a single element slice ('use warnings' complains).'OP\'s' => sub { my $lineno = 100; open( FILE, "$f" ) or die "Can't find $f\n"; my @lines = <FILE>; my $num = @lines; for ( ; $lineno > 0 ; $lineno-- ) { my @tail = @lines[ $num - $lineno ]; } close(FILE); },
Why the explicite splitting? Why not just'`tail -100`' => sub { my @lines = split( /\n/, `tail -100 $f` ); },
Not that it makes a huge difference speedwise.my @lines = `tail -100 $f`;
In reply to Re^2: Out of memory problem when copying contents of file into array (Benchmarks)
by Anonymous Monk
in thread Out of memory problem when copying contents of file into array
by junky123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |