sub AUTOLOAD {
our $AUTOLOAD=~s/.*:://;
no strict;
local $_=$_[0] and *STDOUT->$_($AUTOLOAD)
}
HelloWorld("print");
Pro: You can Give HelloWorld any (syntactically valid) name you like and (as long as the parameter is "print", anyway) its name will be printed, no pre-declaration required.
Con: The specified function inside the quotes has to be a method associated with a file descriptor.
Perl time:
Pro: You can Give HelloWorld any (syntactically valid) name you like and (as long as the parameter is
"print"
, anyway) its name will be printed, no pre-declaration required.Con: The specified function inside the quotes has to be a method associated with a file descriptor.