Subject: | Reference lost |
Hello Adam,
I've attached some simple code which is not working as expected
with Aspect. Somehow the around advise "destroys" the reference.
The code should be self explaining.
I've tested this with Perl 5.8.3 and 5.10.0 running on Linux.
Thanks for creating this cool package,
Matthias Helmling
Subject: | test.pl |
#!/usr/bin/perl
use Aspect;
around { shift->run_original; } call qr/^foo::*/ | call qr/^bar::*/;
sub get_foo {
return new foo();
}
my $bar = new bar();
# this is working
my $foo = &get_foo;
$bar->foo_hello($foo);
# while this isn't
$bar->foo_hello(&get_foo);
#-----------------------------------------------
package foo;
sub new { return bless {}, shift; }
sub hello { print "Hello World\n"; }
#-----------------------------------------------
package bar;
sub new { return bless {}, shift; }
sub foo_hello {
my $self = shift;
my $foo = shift;
$foo->hello;
}