Ilmari,
Thank you.
This was really elegant.
Here is your script after some remaking
to make clear what it is doing:
# ----------------------------------------------------
package UNIVERSAL;
sub myprint {
print "in myprint - 1\n";
print "@_\n";
print "in myprint - 2\n";
@_=@_; # removes 'read-only' behavior
map{s/::/ /g; print} @_;
print "in myprint - end\n";
}
sub AUTOLOAD{
my $ss = ${(caller 0)[3]};
# caler with a parameter in list context
# returns the list, 4th element of which is the
# name of the caller subroutine
print "in autoload - $ss\n";
return $ss; # returns subroutine name
}
Just->another->Perl->hacker->myprint(",\n");
__END__
The output looks like this:
in autoload - Just::another
in autoload - Just::another::Perl
in autoload - Just::another::Perl::hacker
in myprint - 1
Just::another::Perl::hacker ,
in myprint - 2
Just another Perl hacker,
in myprint - end
----------------------------
Warmest Regards
----
Lev Selector
New York
-----Original Message-----
From: Ilmari Karonen [mailto:[EMAIL PROTECTED]]
Sent: Sunday, September 23, 2001 3:30 PM
To: Fun With Perl
Subject: Just->another->Perl->hacker
package UNIVERSAL;sub print {map{s;::; ;g;print}@_=@_}AUTOLOAD{${(caller
0)[3]}}
Just->another->Perl->hacker->print(",\n");
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"TIMTOWTDI, but did you have to pick the ugliest way you could find?"
-- after Michael Carman in comp.lang.perl.misc