You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by David Lloyd <ll...@rebel.net.au> on 2001/06/01 10:31:22 UTC

Apache::StatINC, Embperl and mod_perl problem

Hmmmm....

I have:

(in httpd.conf)
PerlSetEnv PERL5LIB /home/httpd/modules/
PerlSetVar ApacheStatINC_Debug 1
PerlModule Apache::StatINC
PerlInitHandler Apache::StatINC

I'm running under mod_perl and HTML::Embperl is taking care of any files
that end in .epl

I've rolled a little script using embperl that displays
"/home/httpd/modules" as part of the @INC array (it's actually listed
first).

I've made a package called "LMail" with a function (get_mail) that just
iterates over /var/log/maillog and puts it all into an array.

I have:

(in LMail.pm)
@EXPORT_OK=qw(get_mail);

sub get_mail {
# the body goes here
}

My Embperl page (index.epl) has:

[!

use LMail qw(get_mail);

!]

...

[- @result=get_mail() -]

And so forth. I eventually use the <table> auto functions to put the
results into a nice HTML table.

Now, the funny thing is that Apache::StatINC reloads LMail.pm (because I
have debug on and it says so in the error log file) but the changes
don't appear.

Putting it another way, I am using Apache::StatINC and it is reloading
the module. However, Embperl still doesn't pick up the changes and the
only way to force it to is to restart Apache.

I'm running a default RedHat 7.1 Apache, default RedHat 7.1 mod_perl,
but I've had to install HTML::Embperl 1.3.2 manually. Any idea of what
might be tripping me up here?

DSL

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by David Lloyd <ll...@rebel.net.au>.
Gerald!

> "use" generates an alias to LMail::get_mail, so you can call it without the
> need to specify the package name.

Hole in one.

> While StatINC forces a reload of the
> module it can't know of the alias. So the alias inside the Embperl page
> still points to your old code. I guess when you update your Embperl page
> also (so it get's recompiled), it should then point to the new code in your
> module.

That's exactly what's happening. In fact, now the admonition that you
shouldn't turn off "redefining blah subroutine at line xyz" makes sense
and I've seen the light and I've learned something new today :-)

Thanks for your help.

DSL

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by Gerald Richter <ri...@ecos.de>.
>
> > So could you try to write
> >
> > [- @result=LMail::get_mail() -]
> >
> > Does this change anything ?
>
> I tried that and it works perfectly. But I can't quite think of why it
> would work using that form, although I'm sure I'd understand why if
> someone pointed it out to me.
>

"use" generates an alias to LMail::get_mail, so you can call it without the
need to specify the package name. While StatINC forces a reload of the
module it can't know of the alias. So the alias inside the Embperl page
still points to your old code. I guess when you update your Embperl page
also (so it get's recompiled), it should then point to the new code in your
module.

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by David Lloyd <ll...@rebel.net.au>.
Gerald!

> So could you try to write
> 
> [- @result=LMail::get_mail() -]
> 
> Does this change anything ?

I tried that and it works perfectly. But I can't quite think of why it
would work using that form, although I'm sure I'd understand why if
someone pointed it out to me.

DSL

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by Gerald Richter <ri...@ecos.de>.

> 
> Yep!
> 
> It's basically a package based on the example in the Camel Book:
> 
> package LMail;
> require Exporter;
> 
> @ISA=qw(Exporter);
> @EXPORT_OK=qw(get_mail);
> 
> sub get_mail {
> # body
> }
> 
> 

this looks ok.

So could you try to write


[- @result=LMail::get_mail() -]

Does this change anything ?

Gerald




-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by David Lloyd <ll...@rebel.net.au>.
Yep!

It's basically a package based on the example in the Camel Book:

package LMail;
require Exporter;

@ISA=qw(Exporter);
@EXPORT_OK=qw(get_mail);

sub get_mail {
# body
}

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Apache::StatINC, Embperl and mod_perl problem

Posted by Gerald Richter <ri...@ecos.de>.
>
> I have:
>
> (in LMail.pm)

Do you have a

package LMail ;

here ? If not your sub is compiled in the same namespace as the Embperl
page, which could cause such a behaviour.

> @EXPORT_OK=qw(get_mail);
>
> sub get_mail {
> # the body goes here
> }
>


Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Auto Derefencing in an Anchor?

Posted by Gerald Richter <ri...@ecos.de>.
> 
> Why did you allow the references to automatically dereference in the
> Anchor?
> 

As show in the example, you can use it to easily pass parameters:

  [-
  $A = { A => 1, B => 2 } ;  # Hashreference
  @A = (X, 9, Y, 8, Z, 7)
  -]


  <A HREF="http://localhost/tests?[+ $A  +]">  
  <A HREF="http://localhost/tests?[+ \@A +]">

is expanded by Embperl to 


  <A HREF="http://localhost/tests?A=1&B=2">
  <A HREF="http://localhost/tests?X=9&Y=8&Z=7">


So in case of of array X, Y and Z get passed to the next page

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Auto Derefencing in an Anchor?

Posted by Brooklyn Linux Solutions <ru...@mrbrklyn.com>.
Thanks Gerald.

Why did you allow the references to automatically dereference in the
Anchor?

Ruben
-- 
Brooklyn Linux Solutions
http://www.mrbrklyn.com
http://www.brooklynonline.com

1-718-382-5752

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Auto Derefencing in an Anchor?

Posted by Gerald Richter <ri...@ecos.de>.
Hello
> 
> I'm having a strange behavior with embperl which has taken me by suprise.
> I that a sql uery which is returning a an array of array reference.
> 
> I wanted to use the return value as an argument in an anchor:
> 
> I made an error and forgot to dereference it correctly and the result
> should
> have produced an output like ARRAY(0X8888)
> 
> It does this outside of the anchor, but inside the anchor it seems to be
> referencing
> 

Yes, this is the intented behaviour and is documented here:

http://perl.apache.org/embperl/Embperl.pod.4.html#a

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------





---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Auto Derefencing in an Anchor?

Posted by Brooklyn Linux Solutions <ru...@mrbrklyn.com>.

Hello

I'm having a strange behavior with embperl which has taken me by suprise.
I that a sql uery which is returning a an array of array reference.

I wanted to use the return value as an argument in an anchor:

I made an error and forgot to dereference it correctly and the result
should
have produced an output like ARRAY(0X8888)

It does this outside of the anchor, but inside the anchor it seems to be
referencing

This is the code on the server side:

$archives = $obj->records('Select distinct logfile from postings') or warn
"$!";
-]
SIZE OF archive [+ scalar(@$archives) +] [+ $$archives[1]+]<P>
[- 
@archive = map{ $$_[0] =~ s/^log10(\d)(\d{2})/$2-200$1/; $_ } @$archives;
-]
Array [+ @archive +] [+ $archive[0][0] +]
<TABLE border=3><TR><TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>


This is the output on the Browser:

SIZE OF archive 2 ARRAY(0x83b292c)<P>
Array 2 05-2001
<TABLE border=3><TR><TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=05-2001=">
 ARRAY(0x838fcb8)</A> </TD></TR><TR><TD><A
HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=06-2001="> 
ARRAY(0x83b292c)</A> </TD></TR></TABLE>
</TD>
</TR>
</TABLE>


I see no trace of anything in the embperl.log:
[29336]SRC: Line 52: <TR><TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]CMD:  Cmd = 'tr'
[29336]SRC: Line 52: <TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]SRC: Line 52: <A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]CMD:  Cmd = 'a'
[29336]SRC:                                                   [+
$archive[$row] +]
[29336]EVAL<  $archive[$row]
[29336]TAB:  get TabRow = 1, Used = 3
[29336]EVAL> ARRAY(0x83b21a4)
[29336]TAB:  nResult = 1
[29336]SRC: Line 52: [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]EVAL<  $archive[$row]
[29336]TAB:  get TabRow = 1, Used = 4
[29336]EVAL> ARRAY(0x83b21a4)
[29336]TAB:  nResult = 1
[29336]SRC: Line 52: </A> </TD></TR></TABLE>
[29336]SRC: Line 52: </TD></TR></TABLE>
[29336]SRC: Line 52: </TR></TABLE>
[29336]CMD:  Cmd = '/tr'
[29336]TAB:  r -> nTabMode=17 nResult=1 nRow=1 Used=4 nCol=0 Used=0 nCnt=1
Used=0
[29336]SRC: Line 52: </TABLE>
[29336]CMD:  Cmd = '/table'
[29336]TAB:  r -> nTabMode=17 nResult=1 nRow=1 Used=4 nCol=1 Used=0 nCnt=2
Used=0
[29336]SRC: Line 52: <TR><TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]CMD:  Cmd = 'tr'
[29336]SRC: Line 52: <TD><A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>
[29336]SRC: Line 52: <A HREF="http://www2.mrbrklyn.com/appl/fairuse/bydate.html?month=[+
$archive[$row] +]">  [+ $archive[$row] +]</A> </TD></TR></TABLE>


So - I give up.

How is this happening?

Ruben

-- 
Brooklyn Linux Solutions
http://www.mrbrklyn.com
http://www.brooklynonline.com

1-718-382-5752


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org