Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Just to pick a couple of nits in the interest of increasing understanding...

In that poem, the "m mmm" could be replaced with any bareword simply because the poem "won't run" and without strict, throwing around barewords is unlikely to cause compilation errors.

However, if "m mmm" was used in code to actually match something (being a silly way of writing "m//m"), then you could never replace it with "mmmm".

First, m//m is pretty silly code itself. The empty pattern means "reuse the most recent successful regex", and testing (since I so doubt it is documented that I didn't even look for it) shows that when using the empty regex this way, any options are ignored (including /g!); note that this might be considered a bug and get fixed some day, so don't rely on that behavior. So it boils down to being the same as m//, m//mg, m//g, or any other similar code.

But if we wanted to the code to compile to the same optree, then we could replace "=~ m mmm" with "=~ mmm" (note only 3 "m"s, not 4) provided we either didn't use strict or used a version of Perl that doesn't give an error in this case. However, in the absence of "=~", replacing "m mmm" with "mmm" will change the code from m//m (which matches against $_ since there is no "=~") to 'mmm' (which is simply a string constant) unless something else gets in the way such as strict or the declaration of a subroutine named "mmm".

        - tye (but my friends call me "Tye")

In reply to (tye)Re2: Bareword Regex by tye
in thread Bareword Regex by davorg

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [marto]: good morning all

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (5)
    As of 2018-05-21 07:47 GMT
    Find Nodes?
      Voting Booth?