in reply to Return Array from Subroutine
First of all please try to follow basic guidelines in your code.
Here's some pseudo-code on how to return an array:
use strict; use warnings; use Data::Dumper; sub findLines { open(my $error_fh, '<', 'iset_error_log') or die($!); my @lines; while((my $line = <$error_fh>)) { next unless($line =~ /\[notice/); skipp all lines except notic +e # yada, do something to $line push @lines, $line; } close($error_fh); return @lines; } my @found = findLines(); print Dumper(\@found);
To be more memory efficient, you could also return a reference to the array, like this:
# ..... close($error_fh); return \@lines; } my $found = findLines(); print Dumper($found);
|
|---|