in reply to How to fool caller() / use NEXT within a dynamic sub
#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; sub printcaller { return ( caller(1) )[3]; } my $package = "testpackage"; { my $func_name = $package . '::function'; my $sub = sub { local *__ANON__ = $func_name; printcaller() }; no strict 'refs'; *{ $func_name } = $sub; } is( testpackage::function(), 'testpackage::function', 'tricked caller( +)!' );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to fool caller() / use NEXT within a dynamic sub
by betterworld (Curate) on Jul 26, 2005 at 20:35 UTC | |
Re^2: How to fool caller() / use NEXT within a dynamic sub
by xdg (Monsignor) on Jul 26, 2005 at 20:39 UTC | |
by chromatic (Archbishop) on Jul 26, 2005 at 21:29 UTC | |
by betterworld (Curate) on Jul 26, 2005 at 21:08 UTC |