[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] words words words



On Fri, May 19, 2000 at 12:42:58PM -0400, Bernie Cosell wrote:
> On 19 May 2000, at 17:24, Philip Newton wrote:
> 
> > Bernie Cosell wrote:
> > > On 19 May 2000, at 9:17, tayers@bridge.com wrote:
> > > 
> > > Dumb question [as I try to puzzle out how/if this works].  Is this a 
> > > typo:
> > > 
> > > >     @t{@t} = (1) x @t;
> > >       ^
> > >        '%' here, perhaps??
> > 
> > No, '@'. It's a hash slice....
> 
> A brief note in my own defense, lest I get drummed off of FWP: I 
> understand hash slices just fine.  What I don't understand/remember [and 
> I suspect never will] is Perl's baroque (and irregular to my eye) syntax. 
> Somehow an array-indicator with curly-braces *clanked* on my eye, and my 
> [erring] intuition thought it should be a hash-indicator there...
> 
> Since I've betrayed my ignorance, I'll push my luck: is there any other 
> context in Perl in which "@X" refers to the _hash_ named X rather than 
> the array named X?

You can't consider only the prefix, you have to consider the suffix (if
any) as well.

$x           # scalar variable
@x           # array variable
%x           # hash variable
$x[0]        # scalar element of array variable
$x{y}        # scalar element of hash variable
@x[0,1]      # list of elements of array variable
@x{qw/y z/}  # list of elements of hash variable

...and it gets more fun with dereferencing.

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe