convenientstore has asked for the wisdom of the Perl Monks concerning the following question:
is just looking at whichever 50 that occurs first and doing the substituion.if ($cou) { $orig =~ s/\b$itemY\b/$default/; print "$orig\n";
while (<>) { chomp; my $orig = $_; if ($orig =~ /^#/) { print "$_\n"; next; } if ($orig =~ /^$/) { print "$_\n"; next; } if (/(\w+)\s+M\.\d+\s+(s\.\d+)\s+(\S+\s+){6}(\d+)(.+)?$/) { #server1 yahoo.22 s.50 2 ABCCD 192.168.1.1 0 42 BBS + 50 my $cou = 1; my $item = join('@', $2, $1); my $itemY = $4; for my $i_carriers (keys %s_carriers) { if ("$item" eq "$i_carriers") { my $itemX = $s_carriers{$item}; $orig =~ s/\b$itemY\b/$itemX/; print "$orig\n"; $cou = 0; } last if ! $cou; } if ($cou) { $orig =~ s/\b$itemY\b/$default/; print "$orig\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex question
by moritz (Cardinal) on Nov 12, 2007 at 08:50 UTC | |
|
Re: regex question
by narainhere (Monk) on Nov 12, 2007 at 10:34 UTC | |
by johngg (Canon) on Nov 12, 2007 at 11:25 UTC | |
by convenientstore (Pilgrim) on Nov 12, 2007 at 15:55 UTC | |
by convenientstore (Pilgrim) on Nov 12, 2007 at 17:06 UTC | |
by johngg (Canon) on Nov 12, 2007 at 19:21 UTC | |
|
Re: regex question
by siva kumar (Pilgrim) on Nov 12, 2007 at 09:08 UTC |