in reply to Re^3: Here there be camels!
in thread Here there be cammels!

In the second pass the file is closed.

Replies are listed 'Best First'.
Re^5: Here there be camels!
by LanX (Saint) on Feb 28, 2015 at 22:40 UTC
    warn takes a string as argument, so just add the coordinates you want.

    Just let the string end with a newline "\n" to avoid other numbers to be added automatically.

    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.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    PS: Je suis Charlie!