In addition, if your script takes no "filename"-like arguments (arguments not preceeded by an option), consider making IP addresses an optional argument in this respect:$ script --id="1.0.0.1 1.0.0.2 1.0.0.3" # split the resulting variable on spaces $ cat >id.dat 1.0.0.1 1.0.0.2 1.0.0.3 $ script --id=@id.dat
Or, if your script does depend on, say, one additional argument, consider putting that in a flag, either making that option mandatory or using a suitable default (like stdin for a file), or just add it to the list of non-option arguments:Usage: script.pl [-abcde] [ip_address [ip_address ...]]
Multiple arguments after a single option tag is kind of strange for people used to "standard" command line options for scripts and utilities. I would think about re-working the interface instead of trying to force Getopt to play by these other rules.Usage: script.pl [-abcde] -f filename [ip_address [ip_address ...]] Usage: script.pl [-abcde] filename [ip_address [ip_address ...]]
In reply to Re: Getopt Behavior
by Fastolfe
in thread Getopt Behavior
by gaspodethewonderdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |