in reply to (MeowChow) Re2: Syntax for Slice of dereferenced array
in thread Syntax for Slice of dereferenced array

Huh? Isn't 'x,y,s' a single key? I'm using 'x','y','s' now.

But, basically the bareword thing doesn't work on slices, right?

Replies are listed 'Best First'.
(tye)Re: Syntax for Slice of dereferenced array
by tye (Sage) on Jul 22, 2001 at 10:27 UTC

    Mostly. Perl only gives special treatment to single barewords (with optional white space) used as hash keys (inside $h{here} or before =>). @h{x,y,z} isn't using a single bareword so it doesn't get special treatment so it gets parsed as "x",tr,z and then goes looking for two more commas to finish off the tr.

    Note that "x" is also a Perl keyword but can still be used as a bareword here since "x" is only a binary operator and there is no left-hand side in front of "x" so Perl won't treat it as the operator.

    However, you can write a slice and give it a single key, @h{y}, and the special bareword rules apply there. It isn't the "slice" that breaks the rule, it is having something more than a single bareword (+whitespace).

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