Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-11-27 19:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls