Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: How regex works in array mode?

by JavaFan (Canon)
on Apr 26, 2012 at 10:02 UTC ( #967293=note: print w/ replies, xml ) Need Help??


in reply to Re^4: How regex works in array mode?
in thread How regex works in array mode?

Perhaps you haven't replaced it correctly?

use 5.010; my @lines = ("ip:192.168.243.1", "ip:192.168.243.2" =~ /(ip:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/); say for @lines; __END__ ip:192.168.243.1 ip:192.168.243.2
Do note that ip:192.168.243.2 is in @lines only because the pattern matches the entire string. And do note that "ip:192.168.243.1" is not subject to any matching. In fact, the assignment to @lines is equivalent with:
my @lines; $lines[0] = "ip:192.168.243.1"; push @lines, $1 if "ip:192.168.243.2" =~ /(ip:[0-9]{1,3}\.[0-9]{1,3}\. +[0-9]{1,3}\.[0-9]{1,3})/;


Comment on Re^5: How regex works in array mode?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-08-20 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (118 votes), past polls