Re: question about data structures - what does $# mean?



Ed schreef:

#!/usr/bin/perl -w

Get rid of the "-w". Add:

use strict;
use warnings;


my $d = {sid=>["lll"]};
print $#{$d->{sid}}."\n";

There is no need to concatenate, you can just write

print $#{ $d->{sid} }, "\n";


I expect this to print 1, but it prints 0.

Add a line with "$[ = 1;" somewhere above it, and it will.
But you should really read perlvar first.

--
Affijn, Ruud

"Gewoon is een tijger."
.



Relevant Pages