http://qs321.pair.com?node_id=960087


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'