E
Ed
Howdy all!
Here's a little program:
#!/usr/bin/perl -w
my $d = {sid=>["lll"]};
print $#{$d->{sid}}."\n";
I expect this to print 1, but it prints 0.
What's up with that?
As I read this, $d is a ref to an anonymous assoc. array, which
contains one pair of values, named sid, with an anonymous array
containing one element: "lll".
So to get the number of elements in the array I try:
$#{$d->{sid}}
But that does not work. It gives me 0.
Meanwhile, this does work:
scalar(@{$d->{sid}})
Which made me realize I don't really know what the # does when used in
$#{$d->{sid}}.
Any help would be appreciated!
Thanks,
Ed
Here's a little program:
#!/usr/bin/perl -w
my $d = {sid=>["lll"]};
print $#{$d->{sid}}."\n";
I expect this to print 1, but it prints 0.
What's up with that?
As I read this, $d is a ref to an anonymous assoc. array, which
contains one pair of values, named sid, with an anonymous array
containing one element: "lll".
So to get the number of elements in the array I try:
$#{$d->{sid}}
But that does not work. It gives me 0.
Meanwhile, this does work:
scalar(@{$d->{sid}})
Which made me realize I don't really know what the # does when used in
$#{$d->{sid}}.
Any help would be appreciated!
Thanks,
Ed