Undefined subroutine error
Undefined subroutine error
am 14.04.2009 02:21:45 von roberto
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
So,
I've been dealing with trying to figure out an "Undefined subroutine"
error on one of my sites. At first I thought it was something to do
with Apache::ASP, so I sent a message requesting help to that list:
http://mail-archives.apache.org/mod_mbox/perl-asp/200811.mbo x/thread
However, even after upgrading the server from Debian Etch to Lenny and
migrating the site from Apache::ASP to HTML::Mason, I still get the
exact same "Undefined subroutine" error. That makes me think that this
something at a lower level.
If anyone could possibly help or provide any insight, I would really
appreciate it. This has really been causing me to wrack my brain since
it only occurs on the production server and not on the development
server (both are identically configured).
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--2oS5YaxWCcQjTEyO
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknj1w8ACgkQ5SXWIKfIlGQeogCdGmg0EkYUBjRYOgKFR+w9 TFcB
l+gAnimm8SA9MYXiUVmXlD7AdJekvHhp
=fp5r
-----END PGP SIGNATURE-----
--2oS5YaxWCcQjTEyO--
Re: Undefined subroutine error
am 14.04.2009 04:12:27 von Perrin Harkins
On Mon, Apr 13, 2009 at 8:21 PM, Roberto C. S=E1nchez
wrote:
> I've been dealing with trying to figure out an "Undefined subroutine"
> error on one of my sites. =A0At first I thought it was something to do
> with Apache::ASP, so I sent a message requesting help to that list:
> http://mail-archives.apache.org/mod_mbox/perl-asp/200811.mbo x/thread
>
> However, even after upgrading the server from Debian Etch to Lenny and
> migrating the site from Apache::ASP to HTML::Mason, I still get the
> exact same "Undefined subroutine" error. =A0That makes me think that this
> something at a lower level.
In your Image.pm module, do you declare a package name? Do you export
get_image_name()? How do you load this module in your new Mason
setup?
> This has really been causing me to wrack my brain since
> it only occurs on the production server and not on the development
> server (both are identically configured).
Are they really identically configured? Are you sure there isn't a
difference in startup.pl or in MaxRequestsPerChild or something like
that?
- Perrin
Re: Undefined subroutine error
am 14.04.2009 04:54:02 von roberto
--LpQ9ahxlCli8rRTG
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Mon, Apr 13, 2009 at 10:12:27PM -0400, Perrin Harkins wrote:
>=20
> In your Image.pm module, do you declare a package name? Do you export
> get_image_name()? How do you load this module in your new Mason
> setup?
>=20
The entire Example/Image.pm:
----------8<---------->8----------
package Example::Image;
use Image::ExifTool;
use vars qw( %dirs %urls );
sub get_image_data ($;$$) {
my $image_name =3D $_[0];
my $image_src =3D $_[1] ? $_[1] : $urls{'img'};
my $image_dir =3D $_[2] ? $_[2] : $dirs{'img'};
my %image_data;
$image_data{'src'} =3D $image_src . $image_name;
my $info =3D Image::ExifTool::ImageInfo($image_dir . $image_name);
$image_data{'comment'} =3D $$info{'Comment'};
$image_data{'width'} =3D $$info{'ImageWidth'};
$image_data{'height'} =3D $$info{'ImageHeight'};
return %image_data;
}
1;
----------8<---------->8----------
The module is loaded with a 'PerlModule Example::Image' directive. I
have also tried without the PerlModule directive and with 'use' in the
global.asa (for Apache::ASP) and the main component (for HTML::Mason).
> > This has really been causing me to wrack my brain since
> > it only occurs on the production server and not on the development
> > server (both are identically configured).
>=20
> Are they really identically configured? Are you sure there isn't a
> difference in startup.pl or in MaxRequestsPerChild or something like
> that?
>=20
I have no startup.pl and the MaxRequestsPerChild setting is identical
for both servers.
The only differences that I found were mod_include and mod_disk_cache
were enabled on the development server, but not on the production
server. I have enabled them in production to see if that makes a
difference. For the moment, the 500 errors have seemingly disappeared.
However, they have on occasion disappeared only to return after a day or
so.
But for now it appears to be OK for a few tens of thousands of requests.
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--LpQ9ahxlCli8rRTG
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEUEARECAAYFAknj+sIACgkQ5SXWIKfIlGTR6wCfSz9AJJ1SDQvT0Kpzc008 wWhj
rtsAl2k2xLbUoofW007BNtu2V+TbZDI=
=7v6u
-----END PGP SIGNATURE-----
--LpQ9ahxlCli8rRTG--
Re: Undefined subroutine error
am 14.04.2009 05:02:47 von Perrin Harkins
On Mon, Apr 13, 2009 at 10:54 PM, Roberto C. S=E1nchez
wrote:
> The entire Example/Image.pm:
I don't see you exporting get_image_data. Do you call it with a
fully-qualified name then? e.g. Example::Image::get_image_data().
- Perrin
Re: Undefined subroutine error
am 14.04.2009 14:38:52 von roberto
--dDRMvlgZJXvWKvBx
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Mon, Apr 13, 2009 at 10:12:27PM -0400, Perrin Harkins wrote:
>=20
> Are they really identically configured? Are you sure there isn't a
> difference in startup.pl or in MaxRequestsPerChild or something like
> that?
>=20
OK, so the changes to include the mod_include and mod_disk_cache on the
production server did not do the trick. The problem persists.
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--dDRMvlgZJXvWKvBx
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknkg9sACgkQ5SXWIKfIlGR5twCfciQs4Wdt3oTGTdYlSQWU qBGo
ZcAAnR0x672bjOruhBZrqElrEVGh5Z84
=7JYH
-----END PGP SIGNATURE-----
--dDRMvlgZJXvWKvBx--
Re: Undefined subroutine error
am 14.04.2009 18:36:25 von Perrin Harkins
On Tue, Apr 14, 2009 at 8:38 AM, Roberto C. S=E1nchez
wrote:
> OK, so the changes to include the mod_include and mod_disk_cache on the
> production server did not do the trick. =A0The problem persists.
I think it's all about the way you export your function, but you
haven't answered my question about how you call it.
- Perrin
Re: Undefined subroutine error
am 14.04.2009 18:48:10 von roberto
--Km1U/tdNT/EmXiR1
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Apr 14, 2009 at 12:36:25PM -0400, Perrin Harkins wrote:
> On Tue, Apr 14, 2009 at 8:38 AM, Roberto C. S=E1nchez
> wrote:
> > OK, so the changes to include the mod_include and mod_disk_cache on the
> > production server did not do the trick. =A0The problem persists.
>=20
> I think it's all about the way you export your function, but you
> haven't answered my question about how you call it.
>=20
Sorry, I thought that you were asking how I loaded the module. It
appears that you want to know how I call the specific function.
As far as loading the module, I have tried:
- "PerlModule Example::Image" in .htaccess
- "use Example::Image;" in the main HTML::Mason component
As far as calling the function:
- get_image_data('masthead.png', $urls{'img'}, $dirs{'img'});
- Example::Image::get_image_data('masthead.png', $urls{'img'}, $dirs{'img'=
});
As far as "exporting", I'm not sure to what you are referring.
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--Km1U/tdNT/EmXiR1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknkvkMACgkQ5SXWIKfIlGR1gACeM11WZQ1bcJdjBBtTy6wy uVIq
ANIAnR3ljaYouIB4zCiMSeDnq9NaaHvl
=JpQo
-----END PGP SIGNATURE-----
--Km1U/tdNT/EmXiR1--
Re: Undefined subroutine error
am 14.04.2009 19:21:09 von Perrin Harkins
On Tue, Apr 14, 2009 at 12:48 PM, Roberto C. S=E1nchez
wrote:
> As far as loading the module, I have tried:
>
> =A0- "PerlModule Example::Image" in .htaccess
> =A0- "use Example::Image;" in the main HTML::Mason component
Either of those should be ok. If you decide to export the sub later,
you'd need to call it from Mason.
> As far as calling the function:
>
> =A0- get_image_data('masthead.png', $urls{'img'}, $dirs{'img'});
> =A0- Example::Image::get_image_data('masthead.png', $urls{'img'}, $dirs{'=
img'});
Ok, I don't see how the first one could work with the code you've
shown. You're defining the sub in a package, so you either have to
export it or call it with the fully-qualified path, like you do in the
second case.
If you're not familiar with this stuff, read up on exporting in the
perlmod man page or your favorite Perl book.
If you use the second syntax everywhere, I think this problem will go
away. The issue is with the sub being available in your current
namespace, not with loading the module.
- Perrin
Re: Undefined subroutine error
am 14.04.2009 19:34:22 von roberto
--5xSkJheCpeK0RUEJ
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Apr 14, 2009 at 01:21:09PM -0400, Perrin Harkins wrote:
> On Tue, Apr 14, 2009 at 12:48 PM, Roberto C. S=E1nchez
> wrote:
> > As far as loading the module, I have tried:
> >
> > =A0- "PerlModule Example::Image" in .htaccess
> > =A0- "use Example::Image;" in the main HTML::Mason component
>=20
> Either of those should be ok. If you decide to export the sub later,
> you'd need to call it from Mason.
>=20
I'm not sure what you mean by this.
> > As far as calling the function:
> >
> > =A0- get_image_data('masthead.png', $urls{'img'}, $dirs{'img'});
> > =A0- Example::Image::get_image_data('masthead.png', $urls{'img'}, $dirs=
{'img'});
>=20
> Ok, I don't see how the first one could work with the code you've
> shown. You're defining the sub in a package, so you either have to
> export it or call it with the fully-qualified path, like you do in the
> second case.
>=20
I have used the first syntax and have not noticed a different in the
prevalence of the "Undefined subroutine" error between the two.
> If you're not familiar with this stuff, read up on exporting in the
> perlmod man page or your favorite Perl book.
>=20
> If you use the second syntax everywhere, I think this problem will go
> away. The issue is with the sub being available in your current
> namespace, not with loading the module.
>=20
I am currently using the latter call everywhere and it is still
generating the "Undefined subroutine" error.
> - Perrin
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--5xSkJheCpeK0RUEJ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknkyR4ACgkQ5SXWIKfIlGQSOQCbBpVPXO+difuVIuh250yX hwBR
qQoAnRCrWliE87dx3lpGrPOU+UmvPK7l
=qWKU
-----END PGP SIGNATURE-----
--5xSkJheCpeK0RUEJ--
Re: Undefined subroutine error
am 14.04.2009 19:48:49 von torsten.foertsch
On Tue 14 Apr 2009, Roberto C. S=E1nchez wrote:
> I am currently using the latter call everywhere and it is still
> generating the "Undefined subroutine" error.
Would it be possible to post your module? Perhaps you forgot=20
the "package" declaration?
Torsten
=2D-=20
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
Re: Undefined subroutine error
am 14.04.2009 19:56:57 von Perrin Harkins
On Tue, Apr 14, 2009 at 1:34 PM, Roberto C. S=E1nchez
wrote:
> On Tue, Apr 14, 2009 at 01:21:09PM -0400, Perrin Harkins wrote:
>> On Tue, Apr 14, 2009 at 12:48 PM, Roberto C. S=E1nchez
>> wrote:
>> > As far as loading the module, I have tried:
>> >
>> > =A0- "PerlModule Example::Image" in .htaccess
>> > =A0- "use Example::Image;" in the main HTML::Mason component
>>
>> Either of those should be ok. =A0If you decide to export the sub later,
>> you'd need to call it from Mason.
>>
> I'm not sure what you mean by this.
Well, read up about exporting and then it should make more sense.
Perl has namespaces, and when you export a sub you need to export it
to the namespace where you want to call it, which is Mason in this
case.
> I am currently using the latter call everywhere and it is still
> generating the "Undefined subroutine" error.
Then you must not be getting same error message that you posted to the
Apache::ASP list. That was:
&Apache::ASP::Compiles::__ASP__srv_http_www_e_ample_com__x:: get_image_data
This error message is what you get when you haven't defined that sub
in the current namespace and are calling it as get_image_data(). You
wouldn't get this message from calling
Example::Image::get_image_data().
- Perrin
Re: Undefined subroutine error
am 15.04.2009 03:18:04 von roberto
--oLBj+sq0vYjzfsbl
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Apr 14, 2009 at 07:48:49PM +0200, Torsten Foertsch wrote:
> On Tue 14 Apr 2009, Roberto C. S=E1nchez wrote:
> > I am currently using the latter call everywhere and it is still
> > generating the "Undefined subroutine" error.
>=20
> Would it be possible to post your module? Perhaps you forgot=20
> the "package" declaration?
>=20
----------8<---------->8----------
package Example::Image;
use Image::ExifTool;
use vars qw( %dirs %urls );
sub get_image_data ($;$$) {
my $image_name =3D $_[0];
my $image_src =3D $_[1] ? $_[1] : $urls{'img'};
my $image_dir =3D $_[2] ? $_[2] : $dirs{'img'};
my %image_data;
$image_data{'src'} =3D $image_src . $image_name;
my $info =3D Image::ExifTool::ImageInfo($image_dir . $image_name);
$image_data{'comment'} =3D $$info{'Comment'};
$image_data{'width'} =3D $$info{'ImageWidth'};
$image_data{'height'} =3D $$info{'ImageHeight'};
return %image_data;
}
1;
----------8<---------->8----------
Also, let me ephasize that I have three sites using this exact same
module in the same exact manner as the problem site, yet without any
sort of problem.
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--oLBj+sq0vYjzfsbl
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknlNcAACgkQ5SXWIKfIlGSgTgCgryVVre+zFHXUSNSLhLEx iLIe
xVkAoMFUyOsQo1ikI5w2BSH3+j+PJ2HJ
=4zqY
-----END PGP SIGNATURE-----
--oLBj+sq0vYjzfsbl--
Re: Undefined subroutine error
am 15.04.2009 10:29:20 von torsten.foertsch
On Wed 15 Apr 2009, Roberto C. S=E1nchez wrote:
> > Would it be possible to post your module? Perhaps you forgot
> > the "package" declaration?
>
> ----------8<---------->8----------
>
> package Example::Image;
Ok, then how about checking if your module is really loaded.=20
Apache2::Status provides that or you could probably use this=20
PerlResponseHandler (untested):
SetHandler modperl
PerlResponseHandler "sub { \
use Data::Dumper; \
use Apache2::RequestRec(); \
use Apache2::RequestIO(); \
$_[0]->content_type(q{text/plain}); \
$_[0]->print(Dumper(\%INC)); \
return 0; \
}"
It prints %INC to the browser. So you can check if your module is loaded=20
from the correct path.
Torsten
=2D-=20
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
Re: Undefined subroutine error
am 15.04.2009 15:06:20 von roberto
--17pEHd4RhPHOinZp
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Apr 15, 2009 at 10:29:20AM +0200, Torsten Foertsch wrote:
>=20
> Ok, then how about checking if your module is really loaded.=20
> Apache2::Status provides that or you could probably use this=20
> PerlResponseHandler (untested):
>=20
>
> SetHandler modperl
> PerlResponseHandler "sub { \
> use Data::Dumper; \
> use Apache2::RequestRec(); \
> use Apache2::RequestIO(); \
> $_[0]->content_type(q{text/plain}); \
> $_[0]->print(Dumper(\%INC)); \
> return 0; \
> }"
>
>=20
> It prints %INC to the browser. So you can check if your module is loaded=
=20
> from the correct path.
>=20
This is in the output:
'Example/Image.pm' =3D> '/etc/perl/Example/Image.pm'
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--17pEHd4RhPHOinZp
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknl27gACgkQ5SXWIKfIlGRzzgCgxaB1hWzOs7jZ3yCTGqF5 3fxI
ZEQAn3HT1C+QnsA8yHwn7il/Gi4u/5b+
=fHfy
-----END PGP SIGNATURE-----
--17pEHd4RhPHOinZp--
Re: Undefined subroutine error
am 21.04.2009 18:22:25 von roberto
--98e8jtXdkpgskNou
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Apr 14, 2009 at 01:56:57PM -0400, Perrin Harkins wrote:
> On Tue, Apr 14, 2009 at 1:34 PM, Roberto C. S=E1nchez
> wrote:
> > On Tue, Apr 14, 2009 at 01:21:09PM -0400, Perrin Harkins wrote:
> >> On Tue, Apr 14, 2009 at 12:48 PM, Roberto C. S=E1nchez
> >> wrote:
> >> > As far as loading the module, I have tried:
> >> >
> >> > =A0- "PerlModule Example::Image" in .htaccess
> >> > =A0- "use Example::Image;" in the main HTML::Mason component
> >>
> >> Either of those should be ok. =A0If you decide to export the sub later,
> >> you'd need to call it from Mason.
> >>
> > I'm not sure what you mean by this.
>=20
> Well, read up about exporting and then it should make more sense.
> Perl has namespaces, and when you export a sub you need to export it
> to the namespace where you want to call it, which is Mason in this
> case.
>=20
So, on a lark I tried moving the "PerlModule Example::Image" from the
htacess file to the virtual host configuration. I then restarted
apache. So far, it seems to have been working for several days. In the
past, the problem would usually manifest itself within 8 hours or so of
an apache restart.
Could this have something to do with threading?
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--98e8jtXdkpgskNou
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknt8rgACgkQ5SXWIKfIlGS8FgCaA5WT1TE5dWwP3LWaZJLJ 9yI6
iDgAoNLaYkfvAsYnW/ZMZNNk8WmPcBNi
=Pfki
-----END PGP SIGNATURE-----
--98e8jtXdkpgskNou--
Re: Undefined subroutine error
am 21.04.2009 19:30:58 von Perrin Harkins
On Tue, Apr 21, 2009 at 12:22 PM, Roberto C. S=E1nchez
wrote:
> So, on a lark I tried moving the "PerlModule Example::Image" from the
> .htacess file to the virtual host configuration. =A0I then restarted
> apache. =A0So far, it seems to have been working for several days. =A0In =
the
> past, the problem would usually manifest itself within 8 hours or so of
> an apache restart.
Why were you putting it in a .htaccess file? Were you trying to avoid
loading it until people access a certain directory?
> Could this have something to do with threading?
Are you using a threaded MPM? That's not recommended unless you're on
Windows because of memory consumption. I haven't heard any bug
reports about this kind of behavior on threads though.
- Perrin
Re: Undefined subroutine error
am 21.04.2009 20:34:51 von roberto
--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Apr 21, 2009 at 01:30:58PM -0400, Perrin Harkins wrote:
> On Tue, Apr 21, 2009 at 12:22 PM, Roberto C. S=E1nchez
> wrote:
> > So, on a lark I tried moving the "PerlModule Example::Image" from the
> > .htacess file to the virtual host configuration. =A0I then restarted
> > apache. =A0So far, it seems to have been working for several days. =A0I=
n the
> > past, the problem would usually manifest itself within 8 hours or so of
> > an apache restart.
>=20
> Why were you putting it in a .htaccess file? Were you trying to avoid
> loading it until people access a certain directory?
>=20
I have the .htaccess in subversion, but not the virtual host config.
> > Could this have something to do with threading?
>=20
> Are you using a threaded MPM? That's not recommended unless you're on
> Windows because of memory consumption. I haven't heard any bug
> reports about this kind of behavior on threads though.
>=20
I'm actually using apache2-mpm-prefork.
Regards,
-Roberto
--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com
--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknuEcoACgkQ5SXWIKfIlGTWjwCgsN0oKmtQD8Xwn/SMEEV2 8ijE
E6kAoJkHqTV6wLpaqbQE4ndIvdaLqK9e
=Q87E
-----END PGP SIGNATURE-----
--RnlQjJ0d97Da+TV1--