warn "Warning at FILE.pl line 42, <> line 666.\n";
et voila!
Warning at FILE.pl line 42, <> line 666.
besides:
The example code you gave is nonsense, because foreach slurps the whole file, line-numbers are lost.
Better use while !
Otherwise please post code demonstrating your problem and the expected output.
update
If you want the first FILE and NUMBER to be the correct current ones, put your warn into a sub and use caller to get them, before constructing your string.
Alternatively use Carp to report from the callers context.
|