in reply to Surprising Syntax

Here's a simpler program that shows the problem:
$ perl -we 'print v65 => "\n"'; A $
I do think it's a bug, but I'm not sure whether the rest of p5p agrees. I'll post a question on the list.

Abigail

Replies are listed 'Best First'.
Re: Re: Surprising Syntax
by strat (Canon) on Aug 13, 2002 at 12:37 UTC
    Another strange behaviour: If you write
    use constant TEST => 'x'; my %h = (TEST => 1); print foreach keys %hash;
    outputs: TEST and not 'x'

    I think, one of the two behaviours is not ok. I just don't know which one :-)

      That's not surprising at all, because that's exactly what => is supposed to do: autoquote its left hand side if the left hand side is a simple unquoted string.

      TEST is a simple unquoted string, hence it gets quoted, and hence, it's not a constant.

      Compare:

      my %h = (time => 0); print keys %h;
      That also prints the string time, and not a number.

      You could always use +TEST or TEST(), as discussed in the manual page of constant.pm.

      Abigail

        I agree. The surprise was just in the context that a v-string is not autoquoted. So in my eyes, the behaviour with the v-string is not the same as with constants (and other subs) which makes me think that the v-string behaviour really is a bug.

        Best regards,
        perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"