I can see where you're coming from on this. However the most obvious reason is that 
perl has no relationship in scalar context between @somename and %somename.

Your question regarding the "special" $ is not germane to this concept. Each element 
of the array is a separate scalar variable, accessed by each key of the index. 
Therefore to retrieve a scalar value, you must use a scalar reference. In this case 
$key. Other wise you would be asking Perl to find @key (a list) which really doesn't 
exist. That's unless of course you had created it. That's the way I see the thing.


-----Original Message-----
From: "Lance Murray"<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Wed Dec 18 09:02:04 PST 2002
Subject: Confusion on @array vs $array[] vs $array

>Hello:
>
>I have been fairly confused on the intermixing of array naming standards.  If I
>understand correctly, the @array syntaxt is used to refer to the whole array,
>while $array[n] is refered to specific elements.
>
>In my thinking, it would have been less confusing to use @array[n] to address
>specific elements, but Perl complaines bitterly when warnings &/or strict is
>enabled.
>
>Is the rational for the "$"array[] character for identifying "@"array elements
>due to the fact that the $ character has special meaning (denotes variable or
>element) within double quoted text, while the @ sign has no special meanign
>within double quotes.
>
>Anyway, perhaps one of you syntactical thought police could give me some
>insights to the rational.  I find it very confusing that the $ and @ characters
>are supposed to be used interchangeably to denote arrays, particularyly when I'm
>trying to fathom the relation to other issues such as scalar or list context. 
>As I recall, hashes arso use % and @ interchangeably.
>
>Thanks,
>
>Lance
>
>------------------------------------------------------------------------------
>#!/usr/bin/perl
>print "Lance Murray, Information and Communications Systems\n",  # department
>"The Church of Jesus Christ of Latter-Day Saints\n",  # employer and religion
>"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone number and email
>"\"Better to do a little well than a lot poorly (Socrates)\"\n"; # philosophy
>@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
>@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
>($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
>
>------------------------------------------------------------------------------
>This message may contain confidential information, and is intended only for the use 
>of the individual(s) to whom it is addressed.
>
>
>==============================================================================


___________________________________________________
GO.com Mail                                    
Get Your Free, Private E-mail at http://mail.go.com



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to