Front page | perl.perl5.porters |
Postings from February 2004
[perl #26987] Autoloading issue
From:
Isom,Joshua
Date:
February 23, 2004 19:11
Subject:
[perl #26987] Autoloading issue
Message ID:
rt-3.0.8-26987-79101.17.2604682433742@perl.org
# New Ticket Created by "Isom,Joshua"
# Please include the string: [perl #26987]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=26987 >
I wrote an Autoload package to use for a universal AUTOLOAD subroutine for
all my packages. That way it's only written once, and only one to mantain.
A great benefit for me is catching compile errors and the like. Anyway, the
basis of it is like this...
All subroutines are stored as values in a commonly named hash, and the keys
being the names of the subroutines.
I call, say, Date::FullTime which is like this:
$Subs{'FullTime'} = <<'END_SUB';
FormatTime('FullTime', '%W, %N %e %Y, %i:%M:%S %p', 0);
END_SUB
FormatTime isn't yet defined, but is Autoloaded in the same way.
sub FormatTime ($$$);
$Subs{'FormatTime'} = <<'END_SUB';
sub FormatTime ($$$) {
my ($sub, $string, $import) = @_;
# ... generate subroutine code
eval $code;
die $@ if $@;
}
END_SUB
When I call FullTime, it's evaled, which in turn calls FormatTime and it is
autoloaded. FullTime is compiled without problems. So is FormatTime. But
if I do something like:
FullTime(time);
Then not only is FormatTime trying to make the FullTime sub, but somewhere
in the process, FormatTime is called again, with the only argument being the
number for the current time. It tries to call Date::1077524221 for
instance. If FormatTime is predeclared, not Autoloaded, there are no
problems.
---
Flags:
category=
severity=
---
Site configuration information for perl v5.8.2:
Configured by jisom at Mon Jan 5 00:08:30 CST 2004.
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=darwin, osvers=6.8, archname=darwin
uname='darwin huf404a.local. 6.8 darwin kernel version 6.8: wed sep 10
15:20:55 pdt 2003; root:xnuxnu-344.49.obj~2release_ppc power macintosh
powerpc '
config_args='-der'
hint=previous, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-pipe -fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing',
optimize='-Os',
cppflags='-no-cpp-precomp -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing'
ccversion='', gccversion='3.1 20020420 (prerelease)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -flat_namespace'
libpth=/usr/lib
libs=-lm -lc
perllibs=-lm -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -flat_namespace -bundle -undefined suppress'
Locally applied patches:
---
@INC for perl v5.8.2:
/sw/lib/perl5/darwin
/sw/lib/perl5
/sw/lib/perl5/darwin
/System/Library/Perl/darwin
/System/Library/Perl
/Library/Perl/darwin
/Library/Perl
/Library/Perl
/Network/Library/Perl/darwin
/Network/Library/Perl
/Network/Library/Perl
.
---
Environment for perl v5.8.2:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/jisom
LANG=en
LANGUAGE (unset)
LC_ALL=C
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
PERL_BADLANG (unset)
SHELL=/bin/tcsh