in reply to Searching for an alternative to $0

Try using __FILE__ as in ...
print __FILE__ . "[" . __LINE__ ."] Hi there\n";

Plankton: 1% Evil, 99% Hot Gas.