On 8/3/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
snip
> But the expression $hash{"@cdr[2,3,6,7]"} is the same as 
> $hash{join($",@cdr[2,3,6,7])}  You have just replaced one special variable 
> with another and $" is a bad choice since it's default is a space character, 
> which may easily appear in one (or all) of @cdr[2,3,6,7]
>
> A better choice is $hash{$cdr[2]}{$cdr[3]}{$cdr[6]}{$cdr[7]} but you would
> need four for-loops to get to the value.
snip

The use of the special variable $; is not why
$foo{$a[1],$a[2],$a[3],$a[4]} is a bad choice; it is a bad choice
because it is hard to tell if they meant to use
@foo{$a[1],$a[2],$a[3],$a[4]} but screwed up the sigil.  The spaces
are only important if you want to recover the individual values from
the key, and, since you are storing the entire record, you don't even
need the key to get those values.  Why would you create a nested hash?
 This does not appear to be a tree data.  If you want to do it long
hand because you don't want the spaces that using an array slice will
add then simply say

$hash{"{$cdr[2]$cdr[3]$cdr[6]$cdr[7]"}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to