in reply to Re: Syntax for Slice of dereferenced array
in thread Syntax for Slice of dereferenced array

Try
  
($x,$y,$s)= @{$self}{'x,y,s'};
Unless your key is of the form /\w+/, Perl will interpret it as code returning a list of keys.

update: <CajunMan>Confusion</CajunMan> ... didn't understand what you were trying to do - if you want trouble-free barewords, do it like so:
  
($x,$y,$s)= @{$self}{x=>y=>s=>};
Of course, the form you have it in now makes more sense, unless you're obfuscating.

   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Re: Re: Syntax for Slice of dereferenced array
by John M. Dlugosz (Monsignor) on Jul 22, 2001 at 04:14 UTC
    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?

      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")