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

> I want to do that.

And your problem is ...?

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

PS: Je suis Charlie!

PS: see How do I post a question effectively?

Replies are listed 'Best First'.
Re^4: Here there be camels!
by hildred (Initiate) on Feb 28, 2015 at 22:31 UTC
    In the second pass the file is closed.
      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!