[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Self Aware Data routines? (SPOILER)



1999-06-28-18:44:31 Steve Lane:
>[...]
> sub AUTOLOAD { 
>   print "Sorry, I don't see a subroutine called '$AUTOLOAD'\n"; 
> }
>[...]
> for bonus points: create the non-existent subroutine in &AUTOLOAD as a sub
> that prints that it didn't exist a few cycles ago, but does now. don't use
> eval().

Spoiler warning ---























How about:

sub AUTOLOAD {
  no strict qw/refs/;
  *$AUTOLOAD = sub {
        print "'$AUTOLOAD' didn't exist a few cycles ago, but does now.\n";
  };
  goto &$AUTOLOAD;
}

Now I think I will go wash my hands.

-Bennett

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org