Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Trouble with foreach loop.... I think

by mifflin (Curate)
on May 29, 2004 at 03:56 UTC ( [id://357417]=note: print w/replies, xml ) Need Help??


in reply to Trouble with foreach loop.... I think

It looks like you may be trying to print out any lines returned from your netstat command that have the strings "invalid headers" or "packets dropped" in them. If so, I think this may be something that will work for you...
my @netstat = `netstat -s`; my @matches=("invalid headers", "packets dropped"); my $matches = join('|', @matches); foreach (@netstat) { print if /$matches/; }
However, if you go through alot of records this will be slow as it has to reparse the regular expression over and over. If your regex (list of strings to match) is truely variable and you process lots of records then it might be more efficient to assemble some perl code and eval it. The advanced perl book ( the one with the panther on it ) has a good example in it in the eval chapter.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://357417]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-11-02 11:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (10 votes). Check out past polls.