Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Good Afternoon, I cannot seem to figure out why the 3rd pattern match(if statement) does not get triggered. Below is the code and also the results. Thanks in advance for your help.
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
Not sure why it didnt print "Hi!! 1". Thanks again.

In reply to Pattern Matching issue by rookie_monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2023-02-07 21:21 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.