> -----Original Message----- > From: Ben Curran [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 19, 2001 10:54 AM > To: [EMAIL PROTECTED] > Subject: declarations within an if statement. > > > Trying to alter the value of $testfile depending on how many > arguments are > given, using the following: > > if (@ARGV == 2) { > chdir $ARGV[0]; > my $testfile = $ARGV[1]; > } > else { > my $testfile = $ARGV[0]; > }
Note also that this can be handled without the if() by using something like: chdir shift if @ARGV > 1; my $testfile = shift; (assuming you don't need to preserve @ARGV) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]