You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Toni Mueller <su...@oeko.net> on 2000/06/02 16:17:38 UTC

Embperl struggles


Hello,

trying to develop with Embperl I encounter the following
problems:

1. Using a sequence of statements like 

  [-
  open LOG, ">/tmp/logfile.txt";
  print LOG "some debug info: $var\n";
  close LOG;
  -]

  ever gets me the following error:
  error in Perl code: Can't locate object method "CLOSE" via package "HTML::Embperl::Log"

  but I don't understand why. I can't remember getting this error code
  for other Perl code. Defining a function that contains this code and
  require'ing this doesn't help, but using a full-blown package and
  instantiating this is ok, albeit imho heavily oversized.

2. requrire'ing a file that defines some functions sometimes gives me
   an error that the functions in that file are _not_ defined...

3. I have a hard time understanding when to use [- -] and when to use
   [! !] or [* *]. Most of what I've done so far uses [- -] and
   [$ $] (which I so far have no trouble with). The scoping and
   execution time issues are not that clear to me.

Last but not least I'd like some kind of pretty printer since my
Emacs won't help me here. I tried the two things mentioned on the
web, but to no avail (one requiring Xemacs instead of Emacs, too).

This is all with apache 1.3.10, mod-perl 1.21 and Embperl 1.2.1
(I also have no Perl 5.6.0 yet, only 5.005).


Any help is greatly appreciated!


Best Regards,
--Toni++


Re: Embperl struggles

Posted by Toni Mueller <su...@oeko.net>.

Hello all,

On Fri, Jun 02, 2000 at 04:17:38PM +0200, Toni Mueller wrote:
> trying to develop with Embperl I encounter the following
> problems:
> [ stuff deleted ]

before reading _all_ your kind answers gently pushing me
in the right direction I wanted to thank you for that and
excuse myself for bothering you ...

The short answer to most if not all of these problems is
that after reading the manuals, I should re-read them twice,
AND WHEN BEING AWAKE :-( (slap on my back)


Best Regards,
--Toni++


RE: Embperl struggles

Posted by Gerald Richter <ri...@ecos.de>.
>
> 2. requrire'ing a file that defines some functions sometimes gives me
>    an error that the functions in that file are _not_ defined...
>

I append you a mail I write last month that should explain what happens...

> 3. I have a hard time understanding when to use [- -] and when to use
>    [! !] or [* *]. Most of what I've done so far uses [- -] and
>    [$ $] (which I so far have no trouble with). The scoping and
>    execution time issues are not that clear to me.
>

Don't use [*  *] (only if you need recursions), because it is still
experminetal in the current version and has some problems. Use  [!  !] to
define Perl-subroutines, in all other cases use [- -].

For scoping read:

http://perl.apache.org/embperl/Embperl.pod.5.html#Variable_scope_and_cleanup


> Last but not least I'd like some kind of pretty printer since my
> Emacs won't help me here. I tried the two things mentioned on the
> web, but to no avail (one requiring Xemacs instead of Emacs, too).
>

I don't use Emacs, so I can't help you on this issuse, but I am happy to put
anything up on the web, if available.

Gerald

P.S. Support for Embperl is now on the Embperl Mailing list
(embperl@perl.apache.org)

> -----Original Message-----
> From: embperl-return-275-richter=ecos.de@perl.apache.org
> [mailto:embperl-return-275-richter=ecos.de@perl.apache.org]On Behalf Of
> Gerald Richter
> Sent: Friday, April 21, 2000 9:10 PM
> To: Ulrike Schepp; Steven D. Arnold
> Cc: Embperl Mailingliste
> Subject: RE: use module in Embperl (was: problem solved, but still
> weird!)
>
>
> >
> > Standard workaround here is now "apachectl restart" after the change of
> > modules :-/ weird but it really works!
> >
>
> Nothing weird here. Everything is well defined. Just let us try to
> understand how Perl, mod_perl and Embperl works together:
>
> "perldoc -f use" tells us:
>
>   Imports some semantics into the current package from the named module,
>   generally by aliasing certain subroutine or variable names into your
>   package.  It is exactly equivalent to
>
>      BEGIN { require Module; import Module LIST; }
>
>   except that Module must be a bareword.
>
> So what's important here for us is, that use executes a require
> and this is
> always done before any other code is executed.
>
> "perldoc -f require" says (among other things):
>
>   ..., demands that a library file be included if it hasn't already
>   been included.
>
> and
>
>   Note that the file will not be included twice under the same specified
>   name.
>
> So now we know (or should know) that mod_perl starts the Perl interpreter
> once when Apache is started and the Perl interpreter is only
> terminated when
> Apache is terminated. Out of these two things follows, that a
> module that is
> loaded via use or require is only loaded once and will never be reloaded,
> regardless if the source changes or not.
>
> So far this is just standard Perl. Things get's a little bit more
> difficult
> when running under mod_perl (only Unix), because Apache forks a
> set of child
> processes as neccessary and from the moment they are forked, they run on
> their own and don't know of each other. So if a module is loaded at server
> startup time (before the fork), it is loaded in all childs (this
> can be used
> to save memory, because the code will actually only reside once
> in memory),
> but when the modul is loaded inside the child and the source changes, it
> could be happen, that one child has loaded an ealier version and another
> child has loaded a later version of that module, depending on the time the
> module is actualy loaded by the child.
>
> That explains, why sometimes it works and sometimes it doesn't, simply
> because different childs has loaded different versions of the same module
> and when you reload your page you hit different childs of Apache!
>
> Now there is one point that is special to Embperl to add. Since Embperl
> compiles every page in a different namespace, a module that
> doesn't contains
> a "package foo" statement is compiled in the namespace of the
> page where it
> is first loaded. Because Perl will not load the module a second
> time, every
> other page will not see subs and vars that are defined in the
> loaded module.
> This could be simply avoided by giving every module that should be loaded
> via use/require an explicit namespace via the package statement.
>
> So what can we do?
> - If a module change, simply restart Apache. That's works always.
> - use Apache::StatInc. This will do a stat on every loaded module and
> compare the modification time. If the source has changed the module is
> reloaded. This works most times (but not all modules can be cleanly
> reloaded) and as the number of loaded modules increase, your
> sever will slow
> down, because of the stat it has to do for every module.
> - Use "do" instead of "require". do will execute your file everytime it is
> used. This also adds overhead, but this may be accpetable for
> small files or
> in a debugging environement. (NOTE: Be sure to check $@ after a
> do, because
> do works like eval)
>
> I hope now it's seem a little bit less weird..
>
> Gerald
>


non-DSO mod_perl, Embperl, and AIX not working (duplicate ?)

Posted by Greg Estep <ge...@thinkronize.com>.
Sorry if this is a duplicate.  I sent the message yesterday, but I haven't
seen it posted back to me via the list.  We have recently been having
problems with our email services...

---------------------------------------------------------------


I am using IBM's C complier (cc) under AIX 4.3.3 with Apache 1.3.12,
mod_perl 1.24 (statically linked, not DSO), perl 5.00503, and Embperl
1.3b3.

The "offline", "execute function", and "cgi mode" Embperl tests are
all successful. In the "mod_perl" mode, even the simple "ascii" test
fails.  It fails with a seg. fault and a dbx stack trace that looks
like this:

ap_palloc() at 0xd1179d98
EMBPERL__malloc() at 0xd1178b98
EMBPERL_SetupFileData() at 0xd1177118
EMBPERL_SetupRequest() at 0xd1177764
XS_HTML__Embperl_SetupRequest() at 0xd116fcb8
.() at 0x1004a344
.() at 0x100536f0
.() at 0x1002ff98
perl_call_handler(??, ??, ??) at 0x10113f70
perl_run_stacked_handlers(??, ??, ??) at 0x10113160
perl_handler(??) at 0x10111d38
ap_invoke_handler(0x2011f1f0) at 0x100c42bc
process_request_internal(0x2011f1f0) at 0x100f4d6c
ap_process_request(0x2011f1f0) at 0x100f648c
child_main(0x0) at 0x10002d24
make_child(0x200498e0, 0x0, 0x39363aa3) at 0x100025a0
startup_children(0x2) at 0x1000248c
standalone_main(0x4, 0x2ff228c8) at 0x10001928
main(0x4, 0x2ff228c8) at 0x100014b0


To get Embperl.so to successfully build I added "-b erok" to
LDDLFLAGS.  I also tried '-G' with similar results. Without the
modification to LDDLFLAGS I got several "unresolved symbol" errors.

I also get similar results with Embperl 1.2b9, Apache 1.3.9, and
mod_perl 1.23.

BTW, I did not personally compile my perl executable, it is straight
from a fileset on the AIX 4.3.3 CD.  I have, however, upgraded
several modules to their most recent CPAN version.  My 'perl -V'
output looks like this:

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=aix, osvers=4.3.3.0, archname=aix
    uname='aix funny 3 4 000001716600 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -
qmaxmem=16384'
    ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -
qmaxmem=16384'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='ld', ldflags ='-s'
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lnsl -ldbm -ldl -lld -lm -lc -lcrypt -lbsd -lPW -lC_r
    libc=/lib/libc.a, so=a, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='-
bE:perl.exp'
    cccdlflags=' ', lddlflags='-bhalt:4 -bM:SRE -
bI:$(PERL_INC)/perl.exp -bE:$(B
ASEEXT).exp -b noentry -lc'


Characteristics of this binary (from libperl):
  Built under aix
  Compiled at Aug 14 1999 08:59:55
  @INC:
    /usr/opt/perl5/lib/5.00503/aix
    /usr/opt/perl5/lib/5.00503
    /usr/opt/perl5/lib/site_perl/5.005/aix
    /usr/opt/perl5/lib/site_perl/5.005
    .

--
Greg Estep <ge...@thinkronize.com>


RE: Embperl struggles

Posted by Greg Estep <ge...@thinkronize.com>.
The LOG filehandle is predefined by Embperl.  Anything written to it is put
into Embperl's log file (usually /tmp/embperl.log).  If you use a different
name, you will probably be OK.  On the other hand, you can just delete the
call to "open" (and "close) and use the log file Embperl already provides.

BTW, "LOG" and several other variables are discussed in the "Predefined
variables" section of the HTML::Embperl man page.

--
Greg Estep <ge...@thinkronize.com>
#include <std/disclaimer.h>


-----Original Message-----
From: Toni Mueller [mailto:support-modperl@oeko.net]
Sent: Friday, June 02, 2000 10:18 AM
To: modperl@apache.org
Subject: Embperl struggles

Hello,

trying to develop with Embperl I encounter the following
problems:

1. Using a sequence of statements like

  [-
  open LOG, ">/tmp/logfile.txt";
  print LOG "some debug info: $var\n";
  close LOG;
  -]

  ever gets me the following error:
  error in Perl code: Can't locate object method "CLOSE" via package
"HTML::Embperl::Log"

  but I don't understand why. I can't remember getting this error code
  for other Perl code. Defining a function that contains this code and
  require'ing this doesn't help, but using a full-blown package and
  instantiating this is ok, albeit imho heavily oversized.

2. requrire'ing a file that defines some functions sometimes gives me
   an error that the functions in that file are _not_ defined...

3. I have a hard time understanding when to use [- -] and when to use
   [! !] or [* *]. Most of what I've done so far uses [- -] and
   [$ $] (which I so far have no trouble with). The scoping and
   execution time issues are not that clear to me.

Last but not least I'd like some kind of pretty printer since my
Emacs won't help me here. I tried the two things mentioned on the
web, but to no avail (one requiring Xemacs instead of Emacs, too).

This is all with apache 1.3.10, mod-perl 1.21 and Embperl 1.2.1
(I also have no Perl 5.6.0 yet, only 5.005).


Any help is greatly appreciated!


Best Regards,
--Toni++