Angel has asked for the wisdom of the Perl Monks concerning the following question:
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.
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; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: eval inside an object
by ikegami (Patriarch) on Apr 27, 2005 at 16:47 UTC | |
Re: eval inside an object
by salva (Canon) on Apr 27, 2005 at 16:43 UTC | |
by dave_the_m (Monsignor) on Apr 27, 2005 at 17:47 UTC | |
Re: eval inside an object
by sir.shz (Novice) on Apr 27, 2005 at 18:00 UTC | |
by ikegami (Patriarch) on Apr 27, 2005 at 19:52 UTC | |
Re: eval inside an object
by g0n (Priest) on Apr 28, 2005 at 09:34 UTC | |
Re: eval inside an object
by eyepopslikeamosquito (Archbishop) on Apr 28, 2005 at 12:29 UTC | |
Re: eval inside an object
by moot (Chaplain) on Apr 27, 2005 at 16:34 UTC |
Back to
Seekers of Perl Wisdom