Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 the voices are still...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2016-12-04 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (68 votes). Check out past polls.