If you don't really want to use warn, which adds the line number by default, then you can replace the print with your own sub, in which you can use caller to check where the sub got called from:
($package, $filename, $line) = caller;
That should suffice to recreate what warn does.
You can get lots more of info back, if you use a parameter to caller:
($package, $filename, $line, @blahblah) = caller(0);
For example:
#! perl -w
report("Hello, world!");
sub report {
my ($package, $filename, $line) = caller;
print "print from $filename line $line: @_\n";
}
Output:
print from test.pl line 3: Hello, world!
|