in reply to Re^2: Usage of flags in scripts
in thread Usage of flags in scripts

After reading the documentation, I believe this can be done by changing use Getopt::Long; to use Getopt::Long qw(:config require_order);.

require_order

Whether command line arguments are allowed to be mixed with options. Default is disabled unless environment variable POSIXLY_CORRECT has been set, in which case require_order is enabled.

See also permute, which is the opposite of require_order.

Getopt::Long will stop processing flags and such once it sees an argument without a dash.

And you didn't even know bears could type.

Replies are listed 'Best First'.
Re^4: Usage of flags in scripts
by jordandanford (Initiate) on Jan 01, 2009 at 02:19 UTC

    Great, thank you!

Re^4: Usage of flags in scripts
by JadeNB (Chaplain) on Jan 01, 2009 at 18:28 UTC
    This runs into a problem if the negative number is the first argument, since Getopt::Long then has no way to know that it's not a genuine flag. The solution is the usual GNU-style -- flag, which signals the end of options (so that require_order isn't even necessary, though it'll do no harm—besides being more natural, I think).