You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Steven D. Arnold" <st...@permanent.cc> on 2001/04/07 22:29:33 UTC
strange problem
<html>
Hi,<br>
<br>
I have installed mod_perl and EmbPerl successfully. All the tests work and I can do simple EmbPerl scripts. However, I'm trying to do a script that is a little more complicated. The script reads:<br>
<br>
<html><br>
<head><br>
<title>Some Plain tests for Embperl</title><br>
</head><br>
<br>
<body><br>
<br>
[-<br>
<x-tab> </x-tab>use foo;<br>
<x-tab> </x-tab>$mvar = foo->new();<br>
-]<br>
[+<br>
<x-tab> </x-tab>$mvar->print_value()<br>
+]<br>
<br>
</body><br>
</html><br>
<br>
<br>
foo.pm is very simple. It reads:<br>
<br>
package foo;<br>
use strict;<br>
<br>
sub new {<br>
my($class) = @_;<br>
return bless {<br>
"VALUE" => "test succeeded"<br>
}, $class;<br>
}<br>
<br>
sub print_value {<br>
my($self) = @_;<br>
return $self->{VALUE};<br>
}<br>
<br>
1;<br>
<br>
<br>
When I run the script above, I get the error:<br>
<br>
<x-tab> </x-tab>[Wed Apr 19 01:01:57 2000] [error] [554]ERR: 24: Line 8: Error in Perl code: Can't call method "print_value" without a package or object reference at /usr/local/apache/htdocs/embperl/test.html line 11.<br>
<br>
<br>
However, the same thing in a perl script running directly on the machine works fine. I "use foo", create a new foo object and tell it to print_value, which it does with no problem.<br>
<br>
Any idea what I might be doing wrong?<br>
<br>
<br>
steve<br>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: strange problem
Posted by Wim Kerkhoff <wi...@netmaster.com>.
While I'm quite new to embperl (but using it daily), I think I've seen this.
It seems like the [+ +] block isn't seeing the $mvar of the [- -] block.
Try adding "use strict;" and "use vars qw ($mvar);" before the "use foo" in the
[- -] block and see what happens.
On 19-Apr-2000 Steven D. Arnold wrote:
> Hi,
>
> I have installed mod_perl and EmbPerl successfully. All the tests work and
> I can do simple EmbPerl scripts. However, I'm trying to do a script that
> is a little more complicated. The script reads:
>
> <html>
> <head>
> <title>Some Plain tests for Embperl</title>
> </head>
>
> <body>
>
> [-
> use foo;
> $mvar = foo->new();
> -]
> [+
> $mvar->print_value()
> +]
>
> </body>
> </html>
>
>
> foo.pm is very simple. It reads:
>
> package foo;
> use strict;
>
> sub new {
> my($class) = @_;
> return bless {
> "VALUE" => "test succeeded"
> }, $class;
> }
>
> sub print_value {
> my($self) = @_;
> return $self->{VALUE};
> }
>
> 1;
>
>
> When I run the script above, I get the error:
>
> [Wed Apr 19 01:01:57 2000] [error] [554]ERR: 24: Line 8: Error in
> Perl code: Can't call method "print_value" without a package or object
> reference at /usr/local/apache/htdocs/embperl/test.html line 11.
>
>
> However, the same thing in a perl script running directly on the machine
> works fine. I "use foo", create a new foo object and tell it to
> print_value, which it does with no problem.
>
> Any idea what I might be doing wrong?
>
>
> steve
Regards,
Wim Kerkhoff, Software Engineer
NetMaster Networking Solutions
wim@netmaster.com