SPUG: Slice of HashOfHash

Paul Goracke paul at goracke.org
Fri Nov 17 14:48:58 PST 2006


Ivan Heffner wrote:

> This is all fine in a simple case, but know that a hash look-up, while
> relatively cheap, is not free.  Further, taking this example and
> abstracting it into an object-based interface, it become relatively
> expensive and incurs useless overhead.
> 
>   foreach my $family ( $cartoon->families() ) {
>       if ($cartoon->$family->husband() && $cartoon->$family->husband()
> eq 'fred') {
>           print "yes\n";
>       }
>   }

I´m confused: if this is expensive, shouldn't your tests be 
$family->husband() instead of $cartoon->$family->husband()? 
$cartoon->families() _does_ return a list of Family objects, yes?

pg



More information about the spug-list mailing list