in reply to Storing system grep's output to an array in perl
The horrible way, which I do not recommend, would be to shell out with backticks
my @tops = `/bin/grep -i "top-" filename | /usr/bin/awk '(print $3)'`;
A better way would be something like
my @tops; open FILE, "<filename" or die "could not open filename"; while ( <FILE> ) { if ( m/^top \- (\d{2}:\d{2}:\d{2})/ ) { push @tops, $1; } } close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Storing system grep's output to an array in perl
by SuicideJunkie (Vicar) on Mar 07, 2013 at 19:03 UTC |