Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Code asks, in what file do I live?

by Steve_p (Priest)
on Sep 23, 2004 at 20:27 UTC ( [id://393314]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Code asks, in what file do I live?
in thread Code asks, in what file do I live?

Er, actually it returns stuff about the caller of the current subroutine

Well, if you pass in 0 (caller(0)) then you get the caller information for the current stack frame plus some more information.

my $filename = (caller(0))[1];

Replies are listed 'Best First'.
Re^4: Code asks, in what file do I live?
by dave_the_m (Monsignor) on Sep 23, 2004 at 20:46 UTC
    Well, if you pass in 0 (caller(0)) then you get the caller information for the current stack frame
    And the current stack frame still shows who called you, not who you are. You can't determine the current filename using caller:
    $ cat /tmp/x sub f { my $f = (caller(0))[1]; print "I am: ", __FILE__, "\n"; print "caller: $f\n"; } 1; $ perl585 -e 'require "/tmp/x"; f()' I am: /tmp/x caller: -e $

    Dave.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://393314]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-18 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found