Check specific number arguments


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



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.



Arguments are supplied via the ARGV array.

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



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


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 *