Re: Problem with anonymous array in hash
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Mon, 17 Jul 2006 13:00:55 +0200
bernd wrote:
perl -e '@somearr=split(/ /,"11 12 13"); $hash{'array1'}->[0]=50;
$hash{'array1'}->[2]=100;printf("%d\n", scalar(@somearr));
printf("%d\n",
scalar(@$hash{'array1'}))'
Running this on the command line gives:
3
0
The first number is, as expected, the number of elements in the array
since evaluating an array in scalar context gives it's number of
elements. I would have expected "2" as the outcome for the second,
anonymous array stored in the hash, but obviously I am not referencing
to the array, or?
What am I doing wrong?
You are breaking The Golden Rule for debugging Perl code:
perldoc -q debug
Don't post buggy code here without first letting Perl help you fix it by enabling strictures and warnings.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- Problem with anonymous array in hash
- From: bernd
- Problem with anonymous array in hash
- Prev by Date: Re: Problem with anonymous array in hash
- Next by Date: Re: Problem with anonymous array in hash
- Previous by thread: Re: Problem with anonymous array in hash
- Index(es):
Relevant Pages
|