Ooops, what I Really meant was i did (use strict;use warnings;use 5.010;use Carp;) :) Not used to the lingo.
Now I understand what you mean by eval strings, I didn't realize the significance (eval q{} vs eval{}) but I do now.
I tried calling the method dynamically without using references. It seems to work just as fine:
#!/usr/bin/perl use strict; use 5.010; use warnings; use Carp; { package Foo; our $AUTOLOAD; sub AUTOLOAD { eval { sub foo { sub bar { return 'BAR'; } return 'FOO'; } }; + print qq{AUTOLOADing '$AUTOLOAD'}; my $method = $AUTOLOAD; $method =~ s/.*:://; $method eq 'baz' ? eval q{sub baz{ return uc $AUTOLOAD }} :die + "Invalid method."; goto &$method; } } print 'foo? ', exists &Foo::foo; say Foo->foo; print 'bar? ', exists &Foo::bar; say Foo->bar; print 'baz? ', exists &Foo::baz; say Foo->baz; print 'baz? ', exists &Foo::baz; say Foo->baz; ######OUTPUT##### foo? 1FOO bar? 1BAR baz? AUTOLOADing 'Foo::baz'FOO::BAZ #AUTOLOADING prints once baz? 1FOO::BAZ
In reply to Re^4: say statements within 'sub AUTOLOAD'
by ianyappy
in thread say statements within 'sub AUTOLOAD'
by ianyappy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |