Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: RegEx & Approach Question

by atemon (Chaplain)
on Oct 09, 2007 at 14:07 UTC ( [id://643697]=note: print w/replies, xml ) Need Help??


in reply to RegEx & Approach Question

in your regex $2 is

(size/max/drops/flushes).
You need to escape the parenthesis. try the code after escaping (
if ($line =~ m/\s+Input\s+queue:\s+0\/75\/(.*)\/39\s+\(size\/max\/drop +s\/flushes\); \s+Total\s+output drops:\s+(.*)/) { printf("%-20.20s %-22.22s : $line\n",$file,$currentInterface) if ($1 | +| $2 != 0); }
Note: Since ( I think ) I found some mismatch in No. of spaces from your sample text with the regex, I replaced all spaces with \s+ in the regx.

--VC



There are three sides to any argument.....
your side, my side and the right side.

Replies are listed 'Best First'.
Re^2: RegEx & Approach Question
by ikegami (Patriarch) on Oct 09, 2007 at 14:16 UTC

    It's probably best to avoid hardcoding the other numbers.
    Also, much escaping could be avoided by using an alternate delimiter.

    m{\s+Input\s+queue:\s+\d+/\d+/(\d+)/\d+\s+\(size/max/drops/flushes\); +\s+Total\s+output drops:\s+(\d+)/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-18 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found