On Aug 11, 2004, at 11:59 PM, Uri Guttman wrote:
BS> Is there a compelling reason why lc() and friends must return a BS> defined value at all times? Just curious...
i think you have it backwards. lc forces string context upon its
argument and that will convert undef to ''. then it does its thing which
of course will return '' which is defined. you use warnings but did you
see any when you ran this code?
No warnings were issued. When I added 'defined(chop($hash{'three'}))' and 'defined(chomp($hash{'three'}))' while $hash{'three'} was still non-existent, I received 'uninitialized value' warnings. However, these tests were also "TRUE" and had the side effect of autovivifying $hash{'three'}, though its value remained undefined.
I used a hash in the example because I was looking for a way to process defined-but-false values and ignore undefined values, but without a separate call to exists(). Not so critical, but it got me wondering about how lc() works under the hood. I can understand why string context would be assumed, but why can't lc() have the equivalent of 'return unless defined' built into it? I guess for that I'll need
sub lower_case {
return unless defined($_[0]);
return lc($_[0]);
}_______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm

