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

Re: Matching Sequential IP Addresses

by Joost (Canon)
on Apr 03, 2008 at 18:58 UTC ( [id://678242]=note: print w/replies, xml ) Need Help??


in reply to Matching Sequential IP Addresses

I don't exactly understand the question, but looking at your grep example, you probably want map instead. grep should only be used to match entities and pass them through unmodified, map can be used to process entities and change them into something else:
my @segments = map { /^(\d{1,3}\.\d{1,3}\.\d{1,3})/ ? $1 : () } keys %hashIPs;
this pushes $1 onto @segments for each match, and the empty list, IOW: nothing, for no match.

Note that as far as I can see, this is NOT what you want in your case.

Note also that hashes are unordered, so asking about a sequential order of keys is nonsense: they're always unordered unless you order them explicitly using (for instance) my @ordered = sort keys %hash).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found