in reply to Return Array from Subroutine

Something like:
my %ignorables = map { $_ => 1 } qw([notice mpmstats: rdy bsy rd wr ka + log dns cls bsy: in); open my $error_fh, '<', 'iset_error_log'; sub findLines { # Iterates over the lines in the file, putting each into $_ my @all_lines; while (<$error_fh>) { # Only worry about the lines containing [notice if (/\[notice/) { if (/\brdy\b/){ print "\n"; } else { print ","; } my @line = grep { not defined $ignorables{$_} } split /\s+ +/; # Cleanup s/|^\[|notice|[]]//g for @line; # remove [ from [foo # Output the line @line = join(",", @line); s/,,/,/g for @line; print @line; #this is where I would like to return the arr +ay. push @all_lines, @lines; } } return @all_lines; # outside of while loop } &findLines; close $error_fh;

Replies are listed 'Best First'.
Re^2: Return Array from Subroutine
by TJPride (Pilgrim) on Jul 03, 2012 at 02:13 UTC
    I don't know exactly what you're trying to do here. However, this may be more what you want:
    $line = join(',', @line); $line =~ s/,,/,/g; push @all_lines, $line;
Re^2: Return Array from Subroutine
by Anonymous Monk on Jul 03, 2012 at 00:28 UTC

    I get the output:

    , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,Mon,Jun,25,02:19:09,2012,999,1,0,1,0,0,0,0Mon,Jun,25,02:19:09,2012,1, +mod_was_ap22_http.cMon,Jun,25,02:21:09,2012,999,1,0,1,0,0,0,0Mon,Jun, +25,02:21:09,2012,1,mod_was_ap22_http.cMon,Jun,25,02:25:10,2012,999,1, +0,1,0,0,0,0Mon,Jun,25,02:25:10,2012,1,mod_was_ap22_http.cMon,Jun,25,0 +2:56:10,2012,999,1,0,1,0,0,0,0Mon,Jun,25,02:56:10,2012,1,mod_sm22.cpp +Mon,Jun,25,03:00:10,2012,999,1,1,0,0,0,0,0Mon,Jun,25,03:08:10,2012,99 +9,1,0,1,0,0,0,0Mon,Jun,25,03:08:10,2012,1,mod_sm22.cppMon,Jun,25,03:1 +0:10,2012,999,1,0,1,0,0,0,0Mon,Jun,25,03:10:10,2012,1,mod_was_ap22_ht +tp.cMon,Jun,25,03:24:11,2012,999,1,0,1,0,0,0,0Mon,Jun,25,03:24:11,201 +2,1,mod_was_ap22_http.cMon,