SPUG: general hash performance questions
Yitzchak Scott-Thoennes
sthoenna at efn.org
Wed Feb 27 22:00:36 CST 2002
Matt Tucker <tuck at whistlingfish.net> wrote:
>Because empty strings and undefined values, when interpreted as
>numbers, evaluate to 0. Doing $hash{$_}++ the first time gives you the
>equivalent of $hash{$_} = undef + 1, which is interpreted as $hash{$_}
>= 0 + 1.
Its worth noting that if you actually say something like undef() + 1
you'll get a Use of uninitialized value warning. ++ on an undefined
lvalue is deliberately prevented from giving this warning.
Other operators that work this way are: -- += -= .= |= ^= &&= ||=
The undefined value is silently treated as 0 or "".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list