Re: subroutine redefined

2003-06-15 Thread Stas Bekman
Batara Kesuma wrote:
Hi,

I tried using ModPerl::Registry with this piece of CGI code:

#!/usr/bin/perl -w

use CGI;
use strict;
my $cgi = CGI::-new;
print $cgi-header;
our $count = 0;
for (1 .. 5) {
increase_count();
}
sub increase_count {
our $count;
$count++;
print $count . br\n;
}
It gave me this error:
Subroutine increase_count redefined at /var/www/perl/test.pl line 12.
What is the problem?
You must have changed the script, Registry.pm has recompiled it, which has 
redefined the subroutine, and you've received the appropriate warning. If you 
don't wish this to happen, you can say:

no warnings 'redefine';

at the top of your script.

Normally I start my code with:

use strict;
use warnings;
no warnings 'redefine'; # to be remove in production
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


subroutine redefined

2003-06-14 Thread Batara Kesuma
Hi,

I tried using ModPerl::Registry with this piece of CGI code:

#!/usr/bin/perl -w

use CGI;
use strict;
my $cgi = CGI::-new;
print $cgi-header;
our $count = 0;
for (1 .. 5) {
increase_count();
}
sub increase_count {
our $count;
$count++;
print $count . br\n;
}

It gave me this error:
Subroutine increase_count redefined at /var/www/perl/test.pl line 12.

What is the problem?



Re: subroutine redefined

2003-06-14 Thread Batara Kesuma
On Sat, 14 Jun 2003 16:40:15 +0900
Batara Kesuma [EMAIL PROTECTED] wrote:

 What is the problem?

Ok, I just figured out that the error went away if I restarted the httpd
server.



Re: Subroutine redefined errors at startup

2000-07-19 Thread Carl Hansen

On Tue, Jul 18, 2000 at 07:10:07PM -0700, Jim Serio wrote:
 I'm running Perl 5.6 and recently re-compiled Apache 1.3.12 and mod_perl 1.24
 and I'm not getting various redefined errors at startup that I never got 
 before. I've
 also made no changes to my startup file or httpd.conf. Here's a few of the 
 errors:
 
 -
 Subroutine handler redefined at 
 /usr/local/lib/perl5/site_perl/5.6.0/i686-linux/Apache/Registry.pm line 27.
 Subroutine compile redefined at 
 /usr/local/lib/perl5/site_perl/5.6.0/i686-linux/Apache/Registry.pm line 173.
 -
 
 They seem to be focused on Registry and DBI. When I remove the startup.pl
 file from httpd.conf, I get no errors.
 
 Here's the cgi-perl section of httpd.conf:
 
 -
 Location /cgi-perl/
  SetHandler perl-script
  PerlModule Apache::Registry
  PerlHandler Apache::Registry::handler
  PerlModule Apache::DBI
  PerlInitHandler Apache::StatINC
  Options ExecCGI
  PerlSendHeader On
 /Location
 -
 
 Here's part of my startup.pl file:
 
 -
 use Apache::Registry ();
 use Apache::Constants ();
 use Apache::Sandwich ();
 use Apache::Include ();
 use DBI ();
 use Apache::DBI ();
 -
 
 Should I not duplicate these modules and just have all of them in the
 startup file?
 
 Jim
 

from the ApacheDBI-0.87 README:
  " If you plan to use persistent database connections, there is only one thing
  to do: add the following configuration directive to conf/httpd.conf or to
  your startup.pl:
 
   PerlModule Apache::DBI# this comes first !!
     # other modules using DBI
 
compare to your startup.pl.
might be relevant   


-- 
Carl Hansen
Pictopia.com, Inc.
[EMAIL PROTECTED]
510 841 6400 x 117





Re: Subroutine redefined errors at startup

2000-07-18 Thread Ken Williams

[EMAIL PROTECTED] (Jim Serio) wrote:
Here's the cgi-perl section of httpd.conf:

-
Location /cgi-perl/
 SetHandler perl-script
 PerlModule Apache::Registry
 PerlHandler Apache::Registry::handler
 PerlModule Apache::DBI
 PerlInitHandler Apache::StatINC
 Options ExecCGI
 PerlSendHeader On
/Location
-

Here's part of my startup.pl file:

-
use Apache::Registry ();
use Apache::Constants ();
use Apache::Sandwich ();
use Apache::Include ();
use DBI ();
use Apache::DBI ();
-

Should I not duplicate these modules and just have all of them in the
startup file?

Right.  The 'use' statements and 'PerlModule' directives are doing the
same thing, so you only need one or the other.  But it strikes me as odd
anyway that it's actually loading it twice though, because Perl should
see that it's in %INC and not try to load it again.  So there might
indeed be something fishy here, even though it's easily fixable.

By the way, 'PerlModule' directives are traditionally put at the top
level of the config file, outside any directive blocks.  They always
affect the global server anyway, not just the config section they're in.
So it's a bit misleading to put them in a config section.


  ------
  Ken Williams Last Bastion of Euclidity
  [EMAIL PROTECTED]The Math Forum





Subroutine redefined?

2000-06-04 Thread Schuyler D. Erle

Greetings. I'm running Apache/1.3.12 with mod_perl/1.24 and mod_ssl/2.6.4 on a Debian 
system.
(I know mod_ssl and mod_perl on the same server is begging for trouble, but that's the 
way the
site was designed, well before I got there...) We recently recompiled the server with
mod_perl's EVERYTHING=1 to support some code I'm working on which uses stacked 
handlers.

We use Apache::DBI (via PerlModule) to cache connections to a MySQL database. For some 
reason,
when a PerlHandler runs that accesses the database (or perhaps on ChildInit), we get 
several
dozen warnings of the following type dumped to the log:

Subroutine dump_results redefined at /usr/lib/perl5/5.005/i386-linux/DBI.pm 
line 1100,
FILE chunk 13.

The warnings all seem to be coming from DBI.pm. It was also doing this with CGI.pm on 
server
load, but that's Gone Away, for reasons unclear. We get this errors with 
PerlFreshRestart
either On or Off. Obviously turning PerlWarn Off makes them stop, but it also makes 
code
testing difficult. Everything seems to run fine in spite of the warnings, but they 
make the
logs unreadable. 

Currently, the best solution I have is the following, shamelessly borrowed from slash:

Perl
$SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /Subroutine [\w:]+ 
redefined/io };
/Perl

However, that's a band-aid, not a fix. I checked for multiple installations of DBI 
just in case
-- no luck. I have RTFM, twice. I searched through the list archives and have not 
found discussion of this particular problem. What I'd like to know is what's causing 
these warnings and how to make them stop (not just how to keep them from being dummped 
to the log). 

Information on our perl and apache installations follows. Any suggestions would be 
appreciated. Thanks.

SDE

---

perl -V
---
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
osname=linux, osvers=2.2.15pre14, archname=i386-linux
uname='linux them 2.2.15pre14 #2 smp mon mar 13 14:29:00 est 2000 i686 unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
cc='cc', optimize='-O2 ', gccversion=2.95.2 2313 (Debian GNU/Linux)
cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Apr 30 2000 12:08:38
  @INC:
/usr/lib/perl5/5.005/i386-linux
/usr/lib/perl5/5.005
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl
/usr/lib/perl5
.

httpd -V

Server version: Apache/1.3.12 (Unix)
Server built:   Jun  2 2000 22:20:19
Server's Module Magic Number: 19990320:7
Server compiled with
 -D EAPI
 -D HAVE_MMAP
 -D HAVE_SHMGET
 -D USE_SHMGET_SCOREBOARD
 -D USE_MMAP_FILES
 -D USE_FCNTL_SERIALIZED_ACCEPT
 -D HTTPD_ROOT="/usr/local/apache"
 -D SUEXEC_BIN="/usr/local/apache/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/httpd.scoreboard"
 -D DEFAULT_LOCKFILE="logs/httpd.lock"
 -D DEFAULT_XFERLOG="logs/access_log"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
 -D ACCESS_CONFIG_FILE="conf/access.conf"
 -D RESOURCE_CONFIG_FILE="conf/srm.conf"



RegistryLoader causes subroutine redefined errors on import?

1999-10-19 Thread Matt Arnold

I know this topic has been discussed to death, but I think I can add
something new.  :-)

Upon using Apache::RegistryLoader, I noticed my error logs started
filling up with the dreaded "subroutine redefined" error.  These errors
occur at the moment my scripts scripts are preloaded using
Apache::RegistryLoader.

I put together a minimalistic example to demonstrate the problem.
Consider the following module where function "foo" is exported by
default and "bar" is exported on request.

###

package Foo;

use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Exporter ();

@ISA = ('Exporter');
@EXPORT = qw(foo);
@EXPORT_OK = qw(bar);

sub foo {
  return "foo";
}

sub bar {
  return "bar";
}

1;

###

And consider the following script served by Apache::Registry:

###

#!/usr/bin/perl -w

use strict;
use CGI ();
use Foo ();  # works okay, no error
#use Foo;  # causes "Subroutine foo redefined..." error
#use Foo qw(bar);  # causes "Subroutine bar redefined..." error
#use Foo qw(:DEFAULT bar);  # causes errors for both foo and bar

my $q = CGI-new();
print $q-header();
print "Hello World\n";

###

I tried the above script while "use"-ing Foo using the above techniques
(stopping and starting the server each time to retest
Apache::RegistryLoader.)  Upon each server start, RegistryLoader kicked
out the error(s) shown commented above.  So it seems to be the import
process causing the error.

In all cases, the Apache::Registry script works fine.  The error only
appears when the script is preloaded using Apache::RegistryLoader -- I
can suppress the error by not using RegistryLoader.

So what's causing the error?  Why is the subroutine being redefined?

Thanks,
Matt

apache 1.3.6
mod_perl 1.21
perl 5.00503
Apache::Registry 2.01
Apache::RegistryLoader 1.90



Re: RegistryLoader causes subroutine redefined errors on import?

1999-10-19 Thread Stas Bekman

 I know this topic has been discussed to death, but I think I can add
 something new.  :-)
 
 Upon using Apache::RegistryLoader, I noticed my error logs started
 filling up with the dreaded "subroutine redefined" error.  These errors
 occur at the moment my scripts scripts are preloaded using
 Apache::RegistryLoader.
 
 I put together a minimalistic example to demonstrate the problem.
 Consider the following module where function "foo" is exported by
 default and "bar" is exported on request.

I couldn't reproduce the warns you are talking about. I think your
Apache::RegistryLoader just didn't load the file... Try the latest version
from cvs (I've modified it to provide a better diagnostics on failure to
preload). Try it first...

I'm Apache/1.3.10-dev (Unix) mod_perl/1.21_01-dev (linux/perl5.005_03)

 
 ###
 
 package Foo;
 
 use strict;
 use vars qw(@ISA @EXPORT @EXPORT_OK);
 use Exporter ();
 
 @ISA = ('Exporter');
 @EXPORT = qw(foo);
 @EXPORT_OK = qw(bar);
 
 sub foo {
   return "foo";
 }
 
 sub bar {
   return "bar";
 }
 
 1;
 
 ###
 
 And consider the following script served by Apache::Registry:
 
 ###
 
 #!/usr/bin/perl -w
 
 use strict;
 use CGI ();
 use Foo ();  # works okay, no error
 #use Foo;  # causes "Subroutine foo redefined..." error
 #use Foo qw(bar);  # causes "Subroutine bar redefined..." error
 #use Foo qw(:DEFAULT bar);  # causes errors for both foo and bar
 
 my $q = CGI-new();
 print $q-header();
 print "Hello World\n";
 
 ###
 
 I tried the above script while "use"-ing Foo using the above techniques
 (stopping and starting the server each time to retest
 Apache::RegistryLoader.)  Upon each server start, RegistryLoader kicked
 out the error(s) shown commented above.  So it seems to be the import
 process causing the error.
 
 In all cases, the Apache::Registry script works fine.  The error only
 appears when the script is preloaded using Apache::RegistryLoader -- I
 can suppress the error by not using RegistryLoader.
 
 So what's causing the error?  Why is the subroutine being redefined?
 
 Thanks,
 Matt
 
 apache 1.3.6
 mod_perl 1.21
 perl 5.00503
 Apache::Registry 2.01
 Apache::RegistryLoader 1.90
 
 



___
Stas Bekman  mailto:[EMAIL PROTECTED]www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org   www.perl.com  == www.modperl.com  ||  perl.apache.org
single o- + single o-+ = singlesheavenhttp://www.singlesheaven.com