August 1999 | Return to the Perl Hardware Store | Slide #17 |
sub croak { require Carp; *croak = \&Carp::croak; goto &croak; }
The first time you call this, it replaces itself with the real croak.
The second time you try to call it, you just get the real croak directly.
Now just say
croak("I am not a number. I am a free man.");
Alternative: use autouse 'Carp' => 'croak';
Next | Copyright © 1999 M-J. Dominus |