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.&nbsp; All the tests work and I can do simple EmbPerl scripts.&nbsp; However, I'm trying to do a script that is a little more complicated.&nbsp; The script reads:<br>
<br>
&lt;html&gt;<br>
&lt;head&gt;<br>
&lt;title&gt;Some Plain tests for Embperl&lt;/title&gt;<br>
&lt;/head&gt;<br>
<br>
&lt;body&gt;<br>
<br>
[-<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>use foo;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>$mvar = foo-&gt;new();<br>
-]<br>
[+<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>$mvar-&gt;print_value()<br>
+]<br>
<br>
&lt;/body&gt;<br>
&lt;/html&gt;<br>
<br>
<br>
foo.pm is very simple.&nbsp; It reads:<br>
<br>
package foo;<br>
use strict;<br>
<br>
sub new {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my($class) = @_;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bless {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;VALUE&quot; =&gt; &quot;test succeeded&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, $class;<br>
}<br>
<br>
sub print_value {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my($self) = @_;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $self-&gt;{VALUE};<br>
}<br>
<br>
1;<br>
<br>
<br>
When I run the script above, I get the error:<br>
<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>[Wed Apr 19 01:01:57 2000] [error] [554]ERR:&nbsp; 24: Line 8: Error in Perl code: Can't call method &quot;print_value&quot; 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.&nbsp; I &quot;use foo&quot;, 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