Hi - I have just started with Perl and would need your help on this. I am trying to write a program which expects two strings(arguments) from the end user (no less, no more) and I would like to check if the end-user did pass only two arguments. I am using the code below for this task. Pl advice.
#!/usr/local/bin/perl MAIN: { sub chk_args($); my $name1 = <>; my $name2 = <>; ($name1, $name2) = @ARGV; my $num = $#ARGV + 1; chk_args($num); } sub chk_args($) { my $n = @_; if ($n != 2) { print " $n arguments - 2 required \n"; exit 1; } else { return 0; } } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/