Update: I've just had some people tell me that what happened to me does not happen on their machines. Until then, just treat this as another "Ain't life odd" kind of rambling story.

I'm just sharing an learning experience (screwup) that took me half an hour to track down - it was incredibly difficult to find. I literally got it down to a test case of about 20 characters and it still kept blowing up in my face. I was literally commenting out parts of an if statement.

I was using Parse::RecDescent to write (you guessed it), a parser, in which I had put the following code:

if ( ( $val =~ /m/i ) && ( $clamp =~ /y/i ) ) {......}

The parser was blowing up and reporting all sorts of odd errors. If you haven't spotted the error already, take a moment to see if you can spot it.






Here's the correct code:

if ( ( $val =~ m/m/i ) && ( $clamp =~ m/y/i ) ) {......}

Not only was the 'm' in the first conditional being interpreted as the start of a match, the 'y' in the second conditional was being treated as the transliteration operator. So I was copping it coming and going, so to speak.

And this was with strict and warnings switched on. Somehow the evals being used in Parse::RecDescent managed to miss the =~ / and treat the regex as an operator.

This is something I shan't miss in Perl6

____________________
Jeremy
I didn't believe in evil until I dated it.


In reply to Implied operators are maddening by jepri

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.