in reply to Re: [BioPerl] a warning I do not understand omits a sequence
in thread [BioPerl] a warning I do not understand omits a sequence
If the author used exists this would stop autovivification, and allow you to check for a sequence twice!
Just a side note...
In a boolean context such as that of the OPed code fragment,
hash keys are not autovivified at their lowest level, but any 'intervening' keys are. This is also true when exists is used. So with or without exists, as long as autovivification of the '_seq' key does not cause any side effects, the code can check for the pre-existence of $name as often as desired!
Update: However, there is a (possibly very important) difference between the two tests: A key that really and truly does exist in a hash may yet have a value like undef, the empty string, the string '0' or numeric 0 that will evaluate as boolean false.
>perl -wMstrict -MData::Dumper -le "my $hr; die 'huh?' if $hr->{foo}{bar}; print Dumper $hr; undef $hr; print 'hash ref de-init'; die 'huh?' if exists $hr->{foo}{bar}; print Dumper $hr; " $VAR1 = { 'foo' => {} }; hash ref de-init $VAR1 = { 'foo' => {} };
|
|---|