in reply to [Solved] Wrapping code in a sub causes an error I don't understand.

I don't use Pod::Usage, so take this with a large pinch of salt.

The documentation says:

CAVEATS

By default, pod2usage() will use $0 as the path to the pod input file.

And in the case of calling it not as a script but with -e as you have done, then $0 becomes -e so Pod::Usage fails to open that file. The short answer is either don't use Pod::Usage or don't call it like that.

Additionally, pod2usage should exit so all of those && exit clauses would seem to be superfluous.


🦛

Replies are listed 'Best First'.
Re^2: Wrapping code in a sub causes an error I don't understand.
by davies (Monsignor) on Aug 31, 2023 at 09:48 UTC

      Thanks for the reference. There was already a reply in that thread discussing the unnecessary use of && exit and I've added my tuppence here.


      🦛