Chris Ball wrote: > > >>>>> "Sailaja" == Sailaja Gudipati <[EMAIL PROTECTED]> writes: > > 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.".
Actually that is incorrect. If you have a previous regex defined (which the OP did) and you subsequently use an empty regex perl will use the previous regex. perldoc perlop [snip] If the PATTERN evaluates to the empty string, the last successfully matched regular expression is used instead. So if if($ARGV[0] !~ /-f/) print "Wrong switch"; matches /-f/ then if($ARGV[1]) !~ //) print "Empty file name not allowed"; will actually be if($ARGV[1]) !~ /-f/) print "Empty file name not allowed"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]