APM: Interesting hash side effect

ezra pagel ezra at jdba.org
Thu Jan 9 14:59:20 CST 2003


yeah brian, sometimes autovivification is a mixed blessing. this
behavior is discussed in the documentation for exists().

On Thu, 2003-01-09 at 12:45, Brian Michalk wrote:

> I have had a nagging bug that I finally figured out.
> I found that in some cases checking to see if a hash element is defined will
> add to the hash.
> The following line:
>     103     if (defined $self->{keys}{cfg}{$varname}{ref_sub}) {
> will add the hash element, $self->{keys}{cfg}{$varname}.  I had to change my
> code to the following in order to get it to work correctly.
> 
>     102   if (defined $self->{keys}{cfg}{$varname}) {
>     103     if (defined $self->{keys}{cfg}{$varname}{ref_sub}) {
>     104       return $self->{keys}{cfg}{$varname}{ref_sub};
>     105     }
>     106   } else {
>     107     return undef;
>     108   }
> 
> I hope this helps anyone else who cares.
> 
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 
======================================================================
Ezra Pagel                                           Software Engineer
Perl/Java/Oracle                                         ezra at jdba.org
Austin Logistics, Inc.                      epagel at austinlogistics.com
Austin, Texas                                           (512)-651-5644
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/austin/attachments/20030109/0134dedb/attachment.htm


More information about the Austin mailing list