in reply to Finding the size of an array in a hash?
Another thing I haven't seen mentioned yet:
When dealing with nested constructs like this, I find it useful to dereference each level into a temp variable, rather than sling around nested refs. Makes the code easier to read, brings your assumptions about the data's structure to the front, and prevents problems like this, but at a cost in speed and space. I think it's usually a good tradeoff.
So you'd have:
my $lines = $FULLLINES{$key}; my $num = scalar @$lines;
instead of Hofmator's
my $num = @{$FULLLINES{$key}};
It doesn't make a big difference here, but with deeply nested structures it's invaluable.
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
The hell with paco, vote for Erudil!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding the size of an array in a hash?
by waswas-fng (Curate) on Feb 12, 2003 at 05:09 UTC | |
by FoxtrotUniform (Prior) on Feb 12, 2003 at 08:26 UTC |