***This is not an RE***. You need m"this" syntax to make it an RE. The only time you can not use m is if you have syntax $foo =~ /this/ Using the / char as the RE delimiter makes the m implicit. Your 'RE' uses " as the delimiter so needs the m. It does not do what I expect the original programmer thought it would. Here is what it does:

use warnings; my %flows = ( '0' => 1, '00' => 2, '0$' => 3, '0$more' => 4, 'foo0$' = +> 5 ); foreach (keys %flows) { # loop through keys of %flows setting $_ to each key in turn if (!($_ =~ "^0\$")) { print "Orig $_ not matched\n"; } else { print "Orig $_ matched\n"; } if (!($_ =~ m"^0\$")) { print "RE $_ not matched\n"; } else { print "RE $_ matched\n"; } print $/; } __DATA__ Orig 0 matched RE 0 not matched Orig 00 not matched RE 00 not matched Orig 0$more not matched RE 0$more matched Orig 0$ not matched RE 0$ matched Orig foo0$ not matched RE foo0$ not matched

I am intrigued it is not a syntax error or warning. It appears that the intent is to do something if the hash key does not start with the 2 literal chars '0$'. It does not do that as you can see.

cheers

tachyon


In reply to Re: what function of this Regular Expression? by tachyon
in thread what function of this Regular Expression? by iwanthome

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.