Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Match zero times in regex

by TJPride (Pilgrim)
on Dec 13, 2011 at 09:41 UTC ( [id://943292]=note: print w/replies, xml ) Need Help??


in reply to Match zero times in regex

use strict; use warnings; my $mask = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'; while (<DATA>) { chomp; if (@_ = m/permit ip(?: host)?\s+($mask)\s+($mask)\s+($mask)(?:\s+ +($mask))?$/) { no warnings 'uninitialized'; if ($2 eq '192.168.100.0' && $3 eq '0.0.0.255' || $3 eq '192.168.100.0' && $4 eq '0.0.0.255') { print "@_\n"; } } } __DATA__ permit ip host 10.11.1.1 192.168.100.0 0.0.0.255 permit ip 10.11.1.0 0.0.0.255 192.168.100.0 0.0.0.255

Log In?
Username:
Password:

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

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

    No recent polls found