Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Patternmatching IPaddresses

by johngg (Abbot)
on Jun 22, 2013 at 12:34 UTC ( #1040267=note: print w/ replies, xml ) Need Help??

in reply to Patternmatching IPaddresses

A slightly different approach so as to replace each digit of the masked octets with an 'x' rather than the whole octet with a single 'X' just as an exercise.

$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<EOD or die $!; EOD print for map { s{ (\d+\.\d+) (?= (?:\.\d+){2} ) } { do{ my $c = $1; $c =~ tr{0-9}{x}; $c } }xeg; $_; } <$inFH>;' x.x.1.1 x.x.2.2 x.x.3.3 x.x.4.4 $

I hope this is of interest.



Comment on Re: Patternmatching IPaddresses
Download Code
Replies are listed 'Best First'.
Re^2: Patternmatching IPaddresses
by ambrus (Abbot) on Jun 22, 2013 at 19:45 UTC

    Replace each digit with an x? Hehe, that reminds me to the winning entry (bottom of page) of the 2008 Underhanded C Contest. Sure, blacking out each digit makes sense if you're doing this on paper with a black pen, or with a scanned image you do not want to OCR, but not much in a string replacement.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-11-25 16:53 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 (683 votes), past polls