The thing that jumps out at me is the fact that ps output is fixed field format whereas the regexps are matching anywhere on the line of ps output. Therefore it is going to be easier and more reliable to extract fields using substr before then matching their contents against your expressions. For example:
my $flds = [{ name => UID, start => 0, length => 8 }, { name => PID, start => 8, length => 6 ), # etc. # matches the ps header line in this e.g. ]; my $pid = open my $ph, "ps -ef |" or die $!; my @hdr = split /\s+/, <$ph>; while( <$ph> ) { my %line; for my $fld ( @$flds ) { $line{ $fld -> { name } } = substr ( $_, $fld -> { start }, $f +ld -> { length } ); } # and then match $line{ STIME } against regexps. } waitpid $pid, 0; close $ph
-M
Free your mind
In reply to Re: parsing variable input (perlre problem)
by Moron
in thread parsing variable input (perlre problem)
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |