Next | The Perl Hardware Store | DC.pm Version | 43 |
Sometimes you would like to have two functions that do the same thing
Maybe for compatibility, or just for synonyms
Using the same code twice is bad
Cardinal Rule of Computer Programming:
If you wrote the same code twice, you made a mistake.
Simple example:
sub FIRSTKEY { require Carp; Carp::croak("`each' not implemented"); } sub NEXTKEY { require Carp; Carp::croak("`each' not implemented"); }
Solution:
sub FIRSTKEY { ... } BEGIN { *NEXTKEY = \&FIRSTKEY }
Next | Copyright © 2003 M. J. Dominus |