in reply to Executing line number

One possibility:

print STDERR 'file: ' . __FILE__ . ', line: ' . __LINE__ . "\n";

In case you are wondering about all the concatenation, you can't use __FILE__ and __LINE__ inside double quotes. __FILE__ and __LINE are "special literals" and they lose their specialness inside double quotes. To learn more about __FILE__ and __LINE, look at perldata and search for the phrase "Special Literals".

Best, beth

Replies are listed 'Best First'.
Re^2: Executing line number
by Burak (Chaplain) on Sep 09, 2009 at 22:36 UTC
    I think printf() is more clear in such a situation :)
    printf STDERR "file: %s, line: %s\n", __FILE__, __LINE__;
Re^2: Executing line number
by johngg (Canon) on Sep 09, 2009 at 22:32 UTC

    You can use the babycart operator to interpolate bits of code into a double-quoted string, not that it saves much, if any, typing or looks any clearer.

    warn "file: @{ [ __FILE__ ] } line: @{ [ __LINE__ ] } - oops\n";

    I hope this is of interest.

    Cheers,

    JohnGG

      I think that anyone using this idiom must be punished :p