rookie_monk has asked for the wisdom of the Perl Monks concerning the following question:
Not sure why it didnt print "Hi!! 1". Thanks again.use strict; my $SetName = "MR_\\1\\2\\3"; my $orig1 = "P"; my $orig2 = "A"; my $orig3 = "T"; my $new1 = "\\\\3"; my $new2 = "\\\\2"; my $new3 = "\\\\1"; if ($new1 =~ /\\3/) { if ($SetName =~ /\\3/) { print "hi!! 3\n"; $SetName =~ s/$new3/$orig1/; } if ($SetName =~ /\\2/) { print "hi!! 2\n"; $SetName =~ s/$new2/$orig2/; } if ($SetName =~ /\\1/) { print "hi!! 1\n"; $SetName =~ s/$new1/$orig3/; } print "SetName = $SetName\n"; } The output is: Hi!! 3 Hi!! 2 SetName = MR_PA\3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pattern Matching issue
by Anonymous Monk on Sep 13, 2010 at 19:59 UTC | |
by rookie_monk (Novice) on Sep 13, 2010 at 20:23 UTC | |
by kennethk (Abbot) on Sep 13, 2010 at 20:28 UTC | |
by rookie_monk (Novice) on Sep 13, 2010 at 20:29 UTC | |
|
Re: Pattern Matching issue
by changma_ha (Sexton) on Sep 16, 2010 at 09:27 UTC |