Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Strict and runtime sub names

by broquaint (Abbot)
on Sep 10, 2004 at 11:43 UTC ( #390034=note: print w/replies, xml ) Need Help??


in reply to Strict and runtime sub names

I'd simply check if the subroutine exists and if so create the subroutine otherwise croak
use strict; use Carp 'croak'; sub AUTOLOAD { my($name) = $::AUTOLOAD =~ /::([^:'_]+)_$/; my $method = __PACKAGE__->can($name) || croak "Undefined subroutine &$::AUTOLOAD called"; no strict 'refs'; goto &{ *$name = $method }; } sub foo { print "got: @_\n" } foo_(qw/ some args/); __output__ got: some args
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390034]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-11-24 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (351 votes). Check out past polls.

    Notices?