Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: How regex works in array mode?

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

in reply to How regex works in array mode?

The first value is just the first value of @lines. The rest are return values of the match -- which returns each subpattern matched by a set of () in list context. If you want only the first one returned, get rid off all the capturing parens except the outer ones.

Comment on Re: How regex works in array mode?
Replies are listed 'Best First'.
Re^2: How regex works in array mode?
by astronogun (Sexton) on Apr 26, 2012 at 08:32 UTC
    Hmm.. How will I get rid all the capturing parens? Sorry for the noob question. still learning this whole regex thing...
      How will I get rid all the capturing parens?
      An easy way, one that should also speed up your pattern, make it more understandable, and saves typing, is to replace
      Of course, you could also use the Regexp::Common module: but be aware, unlike your pattern, the one in Regexp::Common rejects invalid IP addresses.
        I already replace it and the output is:

        but it doesn't print the "ip:" Is it possible to print the next value in the array? Thanks

        or is this output possible?

        ip: ip:

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2015-11-29 05:54 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 (747 votes), past polls