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).