Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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 $!; 10.128.99.190 10.128.100.100 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 100.100.100.100 200.200.200.200 EOD print for map { s{ (\d+\.\d+) (?= (?:\.\d+){2} ) } { do{ my $c = $1; $c =~ tr{0-9}{x}; $c } }xeg; $_; } <$inFH>;' xx.xxx.99.190 xx.xxx.100.100 x.x.1.1 x.x.2.2 x.x.3.3 x.x.4.4 xxx.xxx.100.100 xxx.xxx.200.200 $

I hope this is of interest.

Cheers,

JohnGG


Comment on Re: Patternmatching IPaddresses
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2014-07-26 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (177 votes), past polls