[Pdx-pm] Newbie question ... built-in for subroutine name?

Joshua Keroes jkeroes at eli.net
Thu Jul 25 16:47:14 CDT 2002

On (Thu, Jul 25 13:18), Earthlink wrote:
> I'm trying to find the perl built-in variable for the current subroutine name (the analog to __FUNCTION__ in gcc)

#!/usr/local/bin/perl -w

use strict;


sub foo {

    my ($package, $filename, $line, $subroutine, $hasargs,
	$wantarray, $evaltext, $is_require, $hints, $bitmask) = caller(0);

    print <<EOB;
package: $package
file:    $filename
line:    $line
sub:     $subroutine



sandbox:~/work/sw/lib/ELI-Devices $ perl ~/caller.pl                                    
package: main
file:    /home/jkeroes/caller.pl
line:    5
sub:     main::foo

perldoc -f caller for more info.

More information about the Pdx-pm-list mailing list