BUG: "sub PKG::my_method" confuses caller() [perl5.8.0 and perl5.6.0]

Hello friends,

i found a fishy behaviour of caller(). It <wrongly> discrimites=20

{
	package Perl;

	sub rules
	{
	}
}

from=20

sub Perl::rules
{
}

EXAMPLE=20

The code below produces this output:

Under perl5.8.0:
Correct, bugsim.pl, 12
main, bugsim.pl, 18

Under perl5.6.0:
Correct, C:\temp\MuratToolsCD\programming\perl\perl-5.8.0\bugsim.pl, 12
main, C:\temp\MuratToolsCD\programming\perl\perl-5.8.0\bugsim.pl, 18

#!/usr/bin/perl

sub info
{
	print join( ', ', caller ), "\n";
}

{
	package Correct;

	sub mymethod
	{
		::info();
	}
}

	sub Buggy::mymethod
	{
		::info();
	}

	Correct->mymethod;

	Buggy->mymethod;

__END__

Greetings,
Murat

Murat Uenalan
--------------------------------
Charit=E9
Rudolf Virchow Hospital
Biomedical Research Center
Berlin / Germany
--------------------------------
Mailto: murat.uenalan@charite.de=20

Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
  Platform:
    osname=3DMSWin32, osvers=3D4.0, archname=3DMSWin32-x86-multi-thread
    uname=3D''
    config_args=3D'undef'
    hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Dundef
    usethreads=3Dundef use5005threads=3Dundef useithreads=3Ddefine
usemultiplicity=3Ddefine
    useperlio=3Ddefine d_sfio=3Dundef uselargefiles=3Dundef =
usesocks=3Dundef
    use64bitint=3Dundef use64bitall=3Dundef uselongdouble=3Dundef
    usemymalloc=3Dn, bincompat5005=3Dundef
  Compiler:
    cc=3D'cl', ccflags =3D'-nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT   -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize=3D'-MD -DNDEBUG -O1',
    cppflags=3D'-DWIN32'
    ccversion=3D'', gccversion=3D'', gccosandvers=3D''
    intsize=3D4, longsize=3D4, ptrsize=3D4, doublesize=3D8, =
byteorder=3D1234
    d_longlong=3Dundef, longlongsize=3D8, d_longdbl=3Ddefine, =
longdblsize=3D10
    ivtype=3D'long', ivsize=3D4, nvtype=3D'double', nvsize=3D8, =
Off_t=3D'off_t',
lseeksize=3D4
    alignbytes=3D8, prototype=3Ddefine
  Linker and Libraries:
    ld=3D'link', ldflags =3D'-nologo -nodefaultlib -release
-libpath:"c:\perl\lib\CORE"  -machine:x86'
    libpth=3D\lib
    libs=3D  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib
odbc32.lib
 odbccp32.lib msvcrt.lib
    perllibs=3D  oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32
...lib odbccp32.lib msvcrt.lib
    libc=3Dmsvcrt.lib, so=3Ddll, useshrplib=3Dyes, libperl=3Dperl58.lib
    gnulibc_version=3D'undef'
  Dynamic Linking:
    dlsrc=3Ddl_win32.xs, dlext=3Ddll, d_dlsymun=3Dundef, ccdlflags=3D' '
    cccdlflags=3D' ', lddlflags=3D'-dll -nologo -nodefaultlib -release
-libpath:"c:\perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS
  Built under MSWin32
  Compiled at Aug 28 2002 10:10:33
  %ENV:
    PERL5LIB=3D"Z:/www/default/public_html/metadot/metadot"
    PERL5_INCLUDE=3D"D:\Programme\Perl\lib\CORE"
  @INC:
    Z:/www/default/public_html/metadot/metadot
    C:/temp/MuratToolsCD/programming/perl/perl-5.8.0/lib
    .

Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
  Platform:
    osname=3DMSWin32, osvers=3D4.0, archname=3DMSWin32-x86-multi-thread
    uname=3D''
    config_args=3D'undef'
    hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Dundef
    usethreads=3Dundef use5005threads=3Dundef useithreads=3Ddefine
usemultiplicity=3Ddefine
    useperlio=3Dundef d_sfio=3Dundef uselargefiles=3Dundef =
usesocks=3Dundef
    use64bitint=3Dundef use64bitall=3Dundef uselongdouble=3Dundef
  Compiler:
    cc=3D'cl', ccflags =3D'-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
    optimize=3D'-O1 -MD -DNDEBUG',
    cppflags=3D'-DWIN32'
    ccversion=3D'', gccversion=3D'', gccosandvers=3D''
    intsize=3D4, longsize=3D4, ptrsize=3D4, doublesize=3D8, =
byteorder=3D1234
    d_longlong=3Dundef, longlongsize=3D8, d_longdbl=3Ddefine, =
longdblsize=3D10
    ivtype=3D'long', ivsize=3D4, nvtype=3D'double', nvsize=3D8, =
Off_t=3D'off_t',
lseeksize=3D4
    alignbytes=3D8, usemymalloc=3Dn, prototype=3Ddefine
  Linker and Libraries:
    ld=3D'link', ldflags =3D'-nologo -nodefaultlib -release
-libpath:"C:/Programme/Perl\lib\CORE"  -machine:x86'
    libpth=3D"C:\Programme\Microsoft Visual Studio\VC98\mfc\lib"
"C:\Programme\Microsoft Visual Studio\VC98\lib" "D:\Dokumente und
Einstellungen\Murat\Eigene Programme\Expat-1.95.2\Libs"
"W:\libiconv-dev-1.7\lib
" "C:\Programme\Perl\lib\CORE"
    libs=3D  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib
odbc32.lib
 odbccp32.lib msvcrt.lib
    perllibs=3D  oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32
...lib odbccp32.lib msvcrt.lib
    libc=3Dmsvcrt.lib, so=3Ddll, useshrplib=3Dyes, libperl=3Dperl56.lib
  Dynamic Linking:
    dlsrc=3Ddl_win32.xs, dlext=3Ddll, d_dlsymun=3Dundef, ccdlflags=3D' '
    cccdlflags=3D' ', lddlflags=3D'-dll -nologo -nodefaultlib -release
-libpath:"C:/Programme/Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS
  Locally applied patches:
        ActivePerl Build 633
  Built under MSWin32
  Compiled at Jun 17 2002 21:33:05
  %ENV:
    PERL5LIB=3D"Z:/www/default/public_html/metadot/metadot"
    PERL5_INCLUDE=3D"D:\Programme\Perl\lib\CORE"
  @INC:
    Z:/www/default/public_html/metadot/metadot
    C:/Programme/Perl/lib
    C:/Programme/Perl/site/lib
    .

0
murat
9/3/2002 9:53:49 AM
perl.perl5.porters 47902 articles. 1 followers. Follow

1 Replies
362 Views

Similar Articles

[PageSpeed] 25

=?Iso-8859-1?Q?Murat_=Dcnalan?= <murat.uenalan@gmx.de> writes:
>Hello friends,
>
>i found a fishy behaviour of caller(). It <wrongly> discrimites 
>
>{
>	package Perl;
>
>	sub rules
>	{
>	}
>}
>
>from 
>
>sub Perl::rules
>{
>}

The bodies of those two subs are in different packages.
This is a feature - i.e. it is defined to be that way.

There is legacy code that does uses that e.g.:

package Perl;

$global = '...';

sub whatever;

sub Something::Else
{
     $global ;   # uses $Perl::global 

     watever();  # calls &Perl::whatever
}


>
>EXAMPLE 
>
>The code below produces this output:
>
>Under perl5.8.0:
>Correct, bugsim.pl, 12
>main, bugsim.pl, 18
>
>Under perl5.6.0:
>Correct, C:\temp\MuratToolsCD\programming\perl\perl-5.8.0\bugsim.pl, 12
>main, C:\temp\MuratToolsCD\programming\perl\perl-5.8.0\bugsim.pl, 18
>
>#!/usr/bin/perl
>
>sub info
>{
>	print join( ', ', caller ), "\n";
>}
>
>{
>	package Correct;
>
>	sub mymethod
>	{
>		::info();
>	}
>}
>
>	sub Buggy::mymethod
>	{
>		::info();
>	}
>
>	Correct->mymethod;
>
>	Buggy->mymethod;
>
>__END__
>
>Greetings,
>Murat
>
>Murat Uenalan
>--------------------------------
>Charité
>Rudolf Virchow Hospital
>Biomedical Research Center
>Berlin / Germany
>--------------------------------
>Mailto: murat.uenalan@charite.de 
>
>Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
>  Platform:
>    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
>    uname=''
>    config_args='undef'
>    hint=recommended, useposix=true, d_sigaction=undef
>    usethreads=undef use5005threads=undef useithreads=define
>usemultiplicity=define
>    useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
>    use64bitint=undef use64bitall=undef uselongdouble=undef
>    usemymalloc=n, bincompat5005=undef
>  Compiler:
>    cc='cl', ccflags ='-nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32
>-D_CONSOLE -DNO_STRICT   -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
>-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
>    optimize='-MD -DNDEBUG -O1',
>    cppflags='-DWIN32'
>    ccversion='', gccversion='', gccosandvers=''
>    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
>    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
>    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
>lseeksize=4
>    alignbytes=8, prototype=define
>  Linker and Libraries:
>    ld='link', ldflags ='-nologo -nodefaultlib -release
>-libpath:"c:\perl\lib\CORE"  -machine:x86'
>    libpth=\lib
>    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
>comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
>netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib
>odbc32.lib
> odbccp32.lib msvcrt.lib
>    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib
>winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
>oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
>version.lib odbc32
>..lib odbccp32.lib msvcrt.lib
>    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
>    gnulibc_version='undef'
>  Dynamic Linking:
>    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
>    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release
>-libpath:"c:\perl\lib\CORE"  -machine:x86'
>
>
>Characteristics of this binary (from libperl):
>  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
>PERL_IMPLICIT_SYS
>  Built under MSWin32
>  Compiled at Aug 28 2002 10:10:33
>  %ENV:
>    PERL5LIB="Z:/www/default/public_html/metadot/metadot"
>    PERL5_INCLUDE="D:\Programme\Perl\lib\CORE"
>  @INC:
>    Z:/www/default/public_html/metadot/metadot
>    C:/temp/MuratToolsCD/programming/perl/perl-5.8.0/lib
>    .
>
>Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
>  Platform:
>    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
>    uname=''
>    config_args='undef'
>    hint=recommended, useposix=true, d_sigaction=undef
>    usethreads=undef use5005threads=undef useithreads=define
>usemultiplicity=define
>    useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
>    use64bitint=undef use64bitall=undef uselongdouble=undef
>  Compiler:
>    cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE
>-DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT
>-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
>    optimize='-O1 -MD -DNDEBUG',
>    cppflags='-DWIN32'
>    ccversion='', gccversion='', gccosandvers=''
>    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
>    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
>    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
>lseeksize=4
>    alignbytes=8, usemymalloc=n, prototype=define
>  Linker and Libraries:
>    ld='link', ldflags ='-nologo -nodefaultlib -release
>-libpath:"C:/Programme/Perl\lib\CORE"  -machine:x86'
>    libpth="C:\Programme\Microsoft Visual Studio\VC98\mfc\lib"
>"C:\Programme\Microsoft Visual Studio\VC98\lib" "D:\Dokumente und
>Einstellungen\Murat\Eigene Programme\Expat-1.95.2\Libs"
>"W:\libiconv-dev-1.7\lib
>" "C:\Programme\Perl\lib\CORE"
>    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
>comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
>netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib
>odbc32.lib
> odbccp32.lib msvcrt.lib
>    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib
>winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
>oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
>version.lib odbc32
>..lib odbccp32.lib msvcrt.lib
>    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
>  Dynamic Linking:
>    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
>    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release
>-libpath:"C:/Programme/Perl\lib\CORE"  -machine:x86'
>
>
>Characteristics of this binary (from libperl):
>  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
>PERL_IMPLICIT_SYS
>  Locally applied patches:
>        ActivePerl Build 633
>  Built under MSWin32
>  Compiled at Jun 17 2002 21:33:05
>  %ENV:
>    PERL5LIB="Z:/www/default/public_html/metadot/metadot"
>    PERL5_INCLUDE="D:\Programme\Perl\lib\CORE"
>  @INC:
>    Z:/www/default/public_html/metadot/metadot
>    C:/Programme/Perl/lib
>    C:/Programme/Perl/site/lib
>    .
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

0
nick
9/3/2002 9:57:45 AM
Reply: