in reply to autoload and selfload
If you were really tricky-minded, you could add new subroutines on the fly, with some eval magic. Rough, untested code follows, as I'm not completely positive of the AUTOLOAD syntax without checking a book:
That's deep magic, and you'd better understand exactly what it does before you even think about using it. (There are only a couple of situations where I'd consider using it, and it would most definitely NOT be available to anyone off the street. Big security risk here.)sub AUTOLOAD { next if $AUTOLOAD =~ /DESTROY/; # be safe my $sub_text = shift; $AUTOLOAD =~ s/.*:://; eval qq|*{$AUTOLOAD} = sub { $sub_text };| # the following goto may require # no strict 'refs'; goto &$AUTOLOAD; }
Update: I added the goto line because jlistf made me think of it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: autoload and selfload
by jlistf (Monk) on Jul 11, 2000 at 00:46 UTC |