Check specific number arguments

[problem]

You want to check a specific number of arguments, have been supplied to your Perl script.

[/problem]

[solution]

This snippet at the example tab, demonstrates how to check that 2 args, were postfixed to the Perl script.

If you only want to check one, then use ARGV!=0, for three 2, etc.

[/solution]

[example]

Arguments are supplied via the ARGV array.

if($#ARGV!=1) { die("Usage: $0 ...n"); }

[/example]

[reference]

[tags]Perl argument handling, Perl Coding School[/tags]

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *