Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: This should be simple (updated)

by steppnav (Initiate)
on Jun 30, 2022 at 12:46 UTC ( [id://11145199]=note: print w/replies, xml ) Need Help??


in reply to Re: This should be simple (updated)
in thread This should be simple

Good input all! Thanks. The comment about stuff not being anchored help me understand why the "throw away the last part of the line" part of the match didn't get the paren following the naive regex pattern (I don't care if it is a valid IP). I had put that '?' non-greedy flag on and with .* an empty string matched. All I had to do was anchor the end with '$'.

That assignement into a list with a capturing /.../ match thing was very interesting. I'm using a goofy while loop to repeatedly capture and the rip off the IP from lines until there is no matching IP pattern, then move on to the next line (while (<>). That assignement using the match looks like I could use it with an array variable on the left and a 'g' on the match to capture all the matching IP's on a given line. I'll try that after coffee.

Thanks again.

Replies are listed 'Best First'.
Re^3: This should be simple (updated)
by AnomalousMonk (Archbishop) on Jun 30, 2022 at 13:24 UTC
    ... using a ... while loop to repeatedly capture and the rip off the IP from lines until there is no matching IP pattern ... use it with an array variable on the left and a 'g' on the match to capture all the matching IP's on a given line.

    Exactly right.


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found