in reply to Re: How to introduce a frustrating bug with a single whitespace
in thread How to introduce a frustrating bug with a single whitespace

Yes, but at least that gets caught with warnings (or -w):

$ perl -we 'print (4+5)*20;' print (...) interpreted as function at -e line 1. Useless use of multiplication (*) in void context at -e line 1.

The whitespace bug described in the original node is the first bug I've had in a while that:

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Replies are listed 'Best First'.
Re^3: How to introduce a frustrating bug with a single whitespace
by TimToady (Parson) on Dec 24, 2007 at 22:05 UTC
    Well, it's kind of you to say that, but given the fact that Perl 6 changed =~ to ~~, it arguably was a design error. (Though this particular failure mode is not why it was changed, but rather the failure of reversing the operator to say ~= instead. It doesn't matter if you reverse ~~.) Anyway, if you split ~~ in Perl 6 with whitespace, it'll parse, but will likely give you a "useless use of ~ in void context" warning.

    By the way, Perl 6 also fixes the "print (4+5)*20" faq...

complex data structure typo (was Re^3: How to introduce a frustrating bug with a single whitespace)
by doom (Deacon) on Dec 31, 2007 at 02:30 UTC

    The whitespace bug described in the original node is the first bug I've had in a while that:
    • wasn't caught by syntax checking (it's valid Perl)
    • wasn't griped about with strict and warnings on
    • wasn't a design error

    I've got one of those, though not a whitespace bug. Just recently I was messing with a data-structure that was supposed to be an array of arrays of arrays:

    $rect_list = [ [ [0, 0], [3, 9 ] ], [ [5, 4], [3, 10] ], [ [7, 8], [9, 11] ]. [ [2, 4], [5, 15] ], [ [1, 9], [9, 13] ], ];

    First question: Can you spot the bug? Second question: Do you know what it does?

      Tricky. ;-)

      The third line of arrays ends in a period (the contatenation operator) rather than a comma (list argument separator). From my limited knowledge of the internals, I would guess this would cause the third and fourth arrays to be placed in string context and concatenated (returning something like ARRAY($mem_add1)ARRAY($mem_add2)). Thus, your 5 element array would contain only 4 elements: 2 AoAs, a meaningless string, and one more AoA.