Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040267]
help
Chatterbox?
[Eily]: started*
[ambrus]: LanX: native speakers are close, but they aren't on the top. there are a _few_ foreigners who have such a thick accent that it takes more time to get used to it and understand the words behind than even the worst native speaker accents.
[ambrus]: but yes, typically native English speakers, who think that English is still their exclusive property, are the worst.
[LanX]: Eily: do you live in an English speaking country?
[LanX]: I think foreigners tend to simplify their phrases, whereby often native speakers don't know how to adapt
[Eily]: nope, France
[LanX]: That's pretty true for every language
[LanX]: so don't worry, anyway most spoken language in the world is broken English
LanX (especially in the streets of Singapore)
[Eily]: yes I know, native English speakers are actually a minority among English speakers :)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-03-27 16:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.