u235sentinel has asked for the wisdom of the Perl Monks concerning the following question:
I've been working with this off and on for some time. I have a couple solutions that work however I don't feel they are as clean as they can be. I'm trying to use a loop and have run into some trouble. I "thought" I was asking perl to print any lines that match my @matches list. It comes back blank. I've been searching several books and google. I'm just not seeing the mistake. What am I missing?
Here is the code. Any insights on what I missed is greatly appreciated.
Here is the code. Any insights on what I missed is greatly appreciated.
use strict; use warnings; my @netstat = `netstat -s`; my @matches=("invalid headers", "packets dropped"); foreach my $matches (@netstat) { my @results = grep(/@matches/, @netstat); #print "I am here\n"; print @results; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Trouble with foreach loop.... I think
by arturo (Vicar) on May 29, 2004 at 03:53 UTC | |
by u235sentinel (Hermit) on Jun 01, 2004 at 16:03 UTC | |
Re: Trouble with foreach loop.... I think
by mifflin (Curate) on May 29, 2004 at 03:56 UTC |
Back to
Seekers of Perl Wisdom