Greetings,
I am messing around with eval since it's cool and trying some stuff. I am trying to run something AUTOLOAD like for experimental sake and I cant seem to get this to work.
I looked at the docs and it says that all local and global vars will be defined in the eval space. And on some simpler non OO tests that works fine. What this thing is tossing for an error is that $self is not defined but I did a dump check and it is. Any reason why $self is not being added to the namespace for he eval in the same function that I am missing?
Thanks in advance
The error message:
Can't call method "get_user" on an undefined value at (eval 1) line 1.
sub get_function
my $self = shift;
my $function = shift;
my @arguments = @_;
my $argument;
my $result;
my $code = '$result = $self->' . $self->{object_methods}{$function
+} . '(';
my $has_arguments;
foreach $argument ( @arguments )
{
$has_arguments = 1;
$code .= "\'$argument\',";
}
if( $has_arguments )
{
chop $code;
}
$code .= ");";
print $code;
eval $code;
if( $@ )
{
$self->{'error_type'} = "mail_merge_function error";
$self->{'error_string'} = "mail_merge_function error $@";
return( undef );
}
else
{
return $result;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.