SPUG: Slice of HashOfHash

DeRykus, Charles E charles.e.derykus at boeing.com
Sun Nov 19 15:37:49 PST 2006


 

>>Ivan Heffner wrote:
>> Use Perl's short-circuiting logical '||'
>> to make a single method call (or set of method calls):
>>
>>   foreach my $family ( $cartoon->families() ) {
>>       if ( ( $cartoon->$family->husband() || '' ) eq 'fred') {
>>            print "yes\n";
>>       }
>>   }

>Or even:
>  ( $cartoon->$family->husband() // '' ) eq 'fred'

Did you perhaps mean  the proposed ?? (hook-hook operator) 
rather than  // ... ? 


-- 
Charles DeRykus

P.S.
for anyone wondering what 'hook-hook' is all about:
http://www.perl.com/tchrist/defop/defconfaq.html


More information about the spug-list mailing list