vyeddula has asked for the wisdom of the Perl Monks concerning the following question:
Pattern matching File
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
My program #!/usr/bin/perl -w use strict; my $source=shift @ARGV; open(FH,'<',$source) or die "I can't open the file $!\n"; while(<FH>) { s/^(\d*).(\d*)/X.X/g; } close FH;
output:
X.X.99.190 10.128.100.100
X.X.1.1 2.2.2.2
X.X.3.3 4.4.4.4
X.X.100.100 200.200.200.200
I want the first 2 octets of other string should also be X and X How to do that?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Patternmatching IPaddresses
by BrowserUk (Patriarch) on Jun 21, 2013 at 22:47 UTC | |
Re: Patternmatching IPaddresses
by choroba (Cardinal) on Jun 21, 2013 at 22:48 UTC | |
Re: Patternmatching IPaddresses
by 2teez (Vicar) on Jun 21, 2013 at 22:53 UTC | |
Re: Patternmatching IPaddresses
by johngg (Canon) on Jun 22, 2013 at 12:34 UTC | |
by ambrus (Abbot) on Jun 22, 2013 at 19:45 UTC | |
Re: Patternmatching IPaddresses
by rjt (Curate) on Jun 22, 2013 at 23:42 UTC | |
Re: Patternmatching IPaddresses
by sundialsvc4 (Abbot) on Jun 24, 2013 at 13:00 UTC |
Back to
Seekers of Perl Wisdom