Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caller() reports $line numbers inconsistantly #4125

Open
p5pRT opened this issue Jun 22, 2001 · 6 comments
Open

caller() reports $line numbers inconsistantly #4125

p5pRT opened this issue Jun 22, 2001 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 22, 2001

Migrated from rt.perl.org#7165 (status was 'stalled')

Searchable as RT7165$

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2001

From jdybnis@yahoo.com


When a function call spans several lines, caller sometimes reports the
first line and other times the last. As illustrated in the following:

my $tag = "#CALLER";

sub tagCall
{
my ($package, $file, $line) = caller;
open CALLER, "$file";
my @lines = <CALLER>;
$lines[$line-1] =~ s/\s?($tag)?(\s*)$/ $tag$2/;
open CALLER, ">$file";
print CALLER @lines;
}

tagCall #CALLER
"abc",
"123",
"foo";

tagCall
"abc",
sub {},
"foo"; #CALLER

It might be that no one else cares about this, but it matters to
me. I will send $100 (US) to whoever fixes this bug (so caller()
always reports the number of the first line of the call) if:

  1. The patch is accepted into the next release of perl.

  2. The patch works under Tru64 and Solaris.

This offer is good until September 1st 2001. Payment by PayPal or
check by mail. I do not follow the Perl mailing lists so contact me
at jdybnis@yahoo.com.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by Josh at Thu Mar 22 16:19:47 2001.

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='', ldflags ='-nologo -nodefaultlib -release 
-libpath:"C:\Program Files\Perl\lib\CORE"  -machine:x86'
    libpth="C:\Program Files\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:\Program Files\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    v5.6.1-TRIAL3
    ACTIVEPERL_LOCAL_PATCHES_ENTRY


@INC for perl v5.6.1:
    C:/Program Files/Perl/lib
    C:/Program Files/Perl/site/lib
    .


Environment for perl v5.6.1:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program
Files\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;c:\cygwin\bin;C:\Program
Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program
Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft
Visual Studio\VC98\bin;C:\Program Files\emacs\bin;C:\Program
Files\WN16\BIN;
    PERL_BADLANG (unset)
    SHELL (unset)


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

@p5pRT
Copy link
Author

p5pRT commented Jul 26, 2008

From p5p@spam.wizbit.be

A much easier example of the code:

#!/usr/bin/perl -l

use strict;
use warnings;

sub tagCall {
  my ($package, $file, $line) = caller;
  print "LINE = $line";
}

tagCall
"abc";

tagCall
sub {};
__END__
tagCall in the source code is on line 11 and on line 14.

Running the script:

LINE = 11
LINE = 15

@p5pRT
Copy link
Author

p5pRT commented May 22, 2012

From @Hugmeir

Hah, I guess that, ten years ago, no one liked money. This is still
present in 5.16.0.

@p5pRT
Copy link
Author

p5pRT commented May 22, 2012

@Hugmeir - Status changed from 'open' to 'stalled'

@toddr
Copy link
Member

toddr commented Jan 31, 2020

Also present on 5.30

@demerphq
Copy link
Collaborator

demerphq commented Jan 31, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants