in reply to Re:Win32... CPU/RAM usage
in thread Win32... CPU/RAM usage

I see your point, however I do want the flexibility in getting all information for all PIDS, but also want the ability to grab certain strings on demand. So my question still remains open for help! I liked you print block and will use that!

Replies are listed 'Best First'.
Re^3: Win32... CPU/RAM usage
by johngg (Canon) on Jul 05, 2007 at 22:31 UTC
    One way to keep that flexibility would be to use something like Getopt::Long so that you could specify multiple items of interest on the command line which would populate an array. (Best to have a look at the documentation for Getopt::Long as I don't have an example to hand.) Then from the array create a compiled regular expression using the pipe symbol for alternation to use in the grep. If you didn't specify anything on the command line the array would be empty so in that case push (or unshift a . (dot) onto the array so the regex would match anything.

    use strict; use warnings; use Getopt::Long; my @wanted = (); GetOptions(q{want=s}, \@wanted); push @wanted, q{.} unless @wanted; my $rxWanted; { local $" = q{|}; $rxWanted = qr{@wanted}; } ... for my $key ( grep { m{$rxWanted} } keys %$info } { ... }

    Again, not tested but I think the concept is sound.

    Cheers,

    JohnGG