in reply to uparse - Parse Unicode strings

BEGIN { if ($] < 5.007003) { warn "$0 requires Perl v5.7.3 or later.\n"; exit; } unless (@ARGV) { warn "Usage: $0 string [string ...]\n"; exit; } }

I'm intrigued as to why you would warn and then immediately exit instead of just die. eg.

BEGIN { die "$0 requires Perl v5.7.3 or later.\n" if $] < 5.007003; die "Usage: $0 string [string ...]\n" unless @ARGV; }

Please enlighten me?


🦛

Replies are listed 'Best First'.
Re^2: uparse - Parse Unicode strings
by kcott (Archbishop) on Nov 18, 2023 at 13:40 UTC

    With my original code, the messages look like this:

    $ uparse /home/ken/local/bin/uparse requires Perl v5.7.3 or later. $ uparse Usage: /home/ken/local/bin/uparse string [string ...]

    With your suggestion, the messages look like this:

    $ uparse /home/ken/local/bin/uparse requires Perl v5.7.3 or later. BEGIN failed--compilation aborted at /home/ken/local/bin/uparse line 1 +5. $ uparse Usage: /home/ken/local/bin/uparse string [string ...] BEGIN failed--compilation aborted at /home/ken/local/bin/uparse line 1 +5.

    I didn't want the "BEGIN failed--compilation aborted at ..." lines.

    — Ken

      Thanks - I understand now. It's for neatness of output (well, stderr really) and is only an issue because of the BEGIN block which itself is necessary for the version check to fire before we hit newer syntax/features.


      🦛