Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Where was I called?

by cephas (Pilgrim)
on Sep 28, 2006 at 13:20 UTC ( #575345=note: print w/replies, xml ) Need Help??


in reply to Where was I called?

This is less than ideal, but it gives you a little better visibility than just line number.
{ my ($line,$occurrence) = (0,0); sub some_sub { $, = ' - '; my @caller = caller(); if($caller[2] == $line) { $occurrence++; } else { $line = $caller[2]; $occurrence = 0; } print @caller, $occurrence, $/; } }
You example shows the biggest limitation to this approach. $occurrence will just keep growing since it is the same line number. But if you know you are dealing with a specific number of calls on the line, you can mod whatever and get the specific occurence on the line.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-06-18 03:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (87 votes). Check out past polls.

    Notices?