in reply to warnings under the debugger

In the first case () is in scalar context so is a pair of empty brackets, not the empty list you may have been expecting. There is no error because => is really just a comma that implictly quotes the bare word to the left. The anon hash is thus the equivelent of {'foo', }. (See List value constructors and Comma Operator.)

Why you get different behaviour in the debugger I don't know however.

Update: strike bogus scalar context comment - see reply.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: warnings under the debugger
by Anno (Deacon) on Mar 08, 2007 at 09:31 UTC
    In both cases the the anonymous hash constructor { foo => () } evaluates its contents in array context.

    On the other hand, I don't see how context would even matter. Either way, foo => () represents a single element, and { scalar( foo => ()) } warns just the same.

    Why the debugger doesn't warn I don't know either.

    Anno