Re: END block weird behavior

[prev] [thread] [next] [Date index for 2004/11/30]

From: Faisal Nasim
Subject: Re: END block weird behavior
Date: 10:34 on 30 Nov 2004
--=====================_64199125==.ALT
Content-Type: text/plain; charset="us-ascii"

Okay here's a demonstration:

The test script is:

#!/usr/local/bin/perl

use strict;
use vars qw ($mydata);

$mydata = 'woodooeer';
my $data = 'woodoo';
my $data2 = 'dingdong';

print "Content-type: text/plain\n\n";

print scalar localtime () , "\n\n";
print `cat /tmp/modperltest.txt`;

END
{
        open FILE , '>/tmp/modperltest.txt';
        print FILE "DATA: " , scalar localtime , "\n";
        print FILE "$data\n";
        print FILE "$mydata\n";
        print FILE "$data2\n";
        close FILE;
}


You can see the different behaviors at:
no modperl: http://www.nasim.org/test/short.cgi
modperl: http://www.nasim.org/test/short.pl

Note that the file is printed first and then updated. Hit refresh
to see that modperl misses $mydata.

Regards,

Faisal



At 01:12 AM 11/27/2004, Faisal Nasim wrote:
>Hi,
>
>I have an END block in my Apache::PerlRun script. First I was trying to print something
>in the END{} block and it didn't show up on the browser. I tried writing to a file and it
>worked great! The weird thing is that when I try to use Dumper() call or any other
>module it doesn't work, it bails out. No 500, nothing in logs but it seems that I can
>no longer use any 'use'd modules. I tried accessing a variable which I was using
>through use vars() and it wasn't available in END {} either. Any ideas what I'm doing
>wrong? Global my() variables are available in the end block only. I looked through the guide
>and mailing list archives, no avail. I'm doing  modperl 1.29 on Apache 1.3.33. Simple
>Apache::PerlRun, no extra modules, no special configuration directives.
>
>Thank you.
>
>Regards,
>
>Faisal

--=====================_64199125==.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<body>
<font size=3>Okay here's a demonstration:<br><br>
The test script is:<br><br>
#!/usr/local/bin/perl<br><br>
use strict;<br>
use vars qw ($mydata);<br><br>
$mydata = 'woodooeer';<br>
my $data = 'woodoo';<br>
my $data2 = 'dingdong';<br><br>
print &quot;Content-type: text/plain\n\n&quot;;<br><br>
print scalar localtime () , &quot;\n\n&quot;;<br>
print `cat /tmp/modperltest.txt`;<br><br>
END<br>
{<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>open FILE
, '&gt;/tmp/modperltest.txt';<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>print FILE
&quot;DATA: &quot; , scalar localtime , &quot;\n&quot;;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>print FILE
&quot;$data\n&quot;;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>print FILE
&quot;$mydata\n&quot;;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>print FILE
&quot;$data2\n&quot;;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>close
FILE;<br>
}<br><br>
<br>
You can see the different behaviors at:<br>
no modperl:
<a href="http://www.nasim.org/test/short.cgi"; eudora="autourl">http://www.nasim.org/test/short.cgi</a><br>;
modperl:
<a href="http://www.nasim.org/test/short.pl"; eudora="autourl">http://www.nasim.org/test/short.pl</a><br><br>;
Note that the file is printed first and then updated. Hit refresh<br>
to see that modperl misses $mydata.<br><br>
Regards,<br><br>
Faisal<br><br>
<br><br>
At 01:12 AM 11/27/2004, Faisal Nasim wrote:<br>
<blockquote type=cite class=cite cite="">Hi,<br><br>
I have an END block in my Apache::PerlRun script. First I was trying to
print something<br>
in the END{} block and it didn't show up on the browser. I tried writing
to a file and it<br>
worked great! The weird thing is that when I try to use Dumper() call or
any other<br>
module it doesn't work, it bails out. No 500, nothing in logs but it
seems that I can<br>
no longer use any 'use'd modules. I tried accessing a variable which I
was using<br>
through use vars() and it wasn't available in END {} either. Any ideas
what I'm doing<br>
wrong? Global my() variables are available in the end block only. I
looked through the guide<br>
and mailing list archives, no avail. I'm doing&nbsp; modperl 1.29 on
Apache 1.3.33. Simple<br>
Apache::PerlRun, no extra modules, no special configuration
directives.<br><br>
Thank you.<br><br>
Regards,<br><br>
Faisal</font></blockquote></body>
</html>

--=====================_64199125==.ALT--


END block weird behavior
Faisal Nasim 20:12 on 26 Nov 2004

Re: END block weird behavior
Faisal Nasim 10:34 on 30 Nov 2004

Re: END block weird behavior
Stas Bekman 00:48 on 02 Dec 2004

Re: END block weird behavior
Faisal Nasim 07:53 on 02 Dec 2004

Re: END block weird behavior
Stas Bekman 15:29 on 02 Dec 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52