in reply to Line numbers
Don't use __LINE__.
Instead use [caller(0)]->[2].
See the documentation for the caller function in perlfunc.
Full example:
sub fatal_error { print STDERR "ERROR: ", @_," ",[caller(0)]->[2]; usage(); exit 1; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Line numbers
by LanX (Saint) on Mar 16, 2012 at 23:18 UTC | |
by tobyink (Canon) on Mar 16, 2012 at 23:33 UTC | |
by chromatic (Archbishop) on Mar 17, 2012 at 00:02 UTC | |
by tobyink (Canon) on Mar 17, 2012 at 00:12 UTC | |
by chromatic (Archbishop) on Mar 17, 2012 at 00:42 UTC | |
by Anonymous Monk on Mar 17, 2012 at 00:39 UTC | |
| |
by LanX (Saint) on Mar 17, 2012 at 00:07 UTC | |
by gg48gg (Sexton) on Mar 17, 2012 at 01:46 UTC | |
by LanX (Saint) on Mar 17, 2012 at 02:04 UTC | |
| |
by Anonymous Monk on Mar 17, 2012 at 02:10 UTC | |
by LanX (Saint) on Mar 17, 2012 at 00:08 UTC | |
by repellent (Priest) on Mar 17, 2012 at 06:51 UTC | |
Re^2: Line numbers
by gg48gg (Sexton) on Mar 16, 2012 at 23:12 UTC |
In Section
Seekers of Perl Wisdom