I wonder what he was thinking...
The hash-style usage of constant wasn't added until perl 5.7.1, and the defined $name check was around before that. Basically all of 5.7.0's code was kept intact and put in the for loop. The defined $name check was just accidentally (I presume) left inside the for loop.
Here's how it should look.
Not that this matters much, becausemy $multiple = ref $_[0]; if ( $multiple ) { ... } else { unless (defined $_[0]) { require Carp; Carp::croak("Can't use undef as constant name"); } $constants{+shift} = undef; } foreach my $name ( keys %constants ) { ... }
will fail anyway. You just get a slightly less clear error message.use constant undef, 'x';
lodin
In reply to Re^2: undef as a key in a hash. (constant.pm "bug")
by lodin
in thread undef as a key in a hash.
by fenLisesi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |