>>>>> "Sailaja" == Sailaja Gudipati <[EMAIL PROTECTED]> writes:
Sailaja> myscript.pl -f test.txt Sailaja> if($#ARGV < 2) { print $USAGE; } $# returns the _last element index_ in the array. As I pointed out in my last mail, array indexes are zero-indexed, not one-indexed. Your if conditional will only become true on _three_ or more arguments. Sailaja> BTW, what is this $USAGE. I saw it in some books and just Sailaja> copied here. Please let me know how to use $USAGE also. $USAGE isn't a special variable. If you want to use this code, you'll have to define $USAGE to be a string telling the user how many variables to pass, such as: $USAGE = '$0 <var1> <var2>'; Sailaja> if($ARGV[0] !~ /-f/) print "Wrong switch"; This looks fine, though you need braces around the print statement. Also note that 'foo-fbar' matches this regexp. I'd use: if ($ARGV[0] ne '-f') { print "Wrong switch"; } Sailaja> if($ARGV[1]) !~ //) print "Empty file name not allowed"; This doesn't make sense. You're saying "If the second argument is not equal to nothing, then print an error saying that the second argument should be not equal to nothing.". The correct line would be: if ($ARGV[1]) =~ //) { print "Empty file name not allowed"; } in your style, or: unless ($ARGV[1]) { print "Empty file name not allowed" } should work just fine. _However_, this is already being picked up by your check on the number of elements in @ARGV, since an empty string won't appear as an array element. Sailaja> But, since @ARGV is empty, I am unable to validate the Sailaja> command line arguments. The errors are with your code, rather than the population of @ARGV, in my opinion. There are certain situations where both could be the case, though, as someone else described for Windows. Hope this helps, - Chris. -- $a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a As to luck, there's the old miners' proverb: Gold is where you find it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]