On the right hand side of the = operator you have a substitution operator. Here's how the operator looks: s/PATTERN/REPLACEMENT/FLAGS. So the pattern is \*, which really means the literal * character. The replacement is the literal text "$lvl=". As often as '*' appears in the target string, it will be replaced with '$lvl='.

There is no binding operator, so this regular expression is matching and substituting against the contents of $_, the implicit "it" or "topic" variable. In other words, in the absence of an explicit target, the regexp operators bind to $_. (Or was it just a typo in your code that there is no =~ operator?)

The return value of a s///g or m//g operator in scalar context will be a true value if there was at least one match, and a false value otherwise. The true value that is returned in scalar context is defined to be the count of how many times the operator matched. The return value will be assigned to $tmp.


Dave


In reply to Re: perl statement by davido
in thread perl statement by Yisha sharma

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.