in reply to 'Ambiguous call' diagnosis seems ambiguous
Perl's tokenizer classifies some keywords as "weak keywords" such that you can override them with user-defined functions. (Calling them is another matter.) delete is a weak keyword and each is not. our is weak, but sub is not:
use strict; use warnings; sub each { warn 'main::each() was called' } sub delete { warn 'main::delete() was called' } sub dump { warn 'main::dump() was called' } sub chop { warn 'main::chop() was called' } sub our { warn 'main::our() was called' } my %person = ( name => 'Ken Takakura' ); while ( my ($key, $val) = each %person ) { print "$key: $val\n"; } &our( $person{name} ); delete $person{name}; chop $person{name}; dump( $person{name} );
I don't know how to make a list of weak and normal keywords without reading the source code (keywords.c or regen/keywords.pl).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 'Ambiguous call' diagnosis seems ambiguous
by anazawa (Scribe) on Aug 03, 2012 at 01:45 UTC |