@_ is a list and $vInput is a scalar. A list in scalar context returns the
number of elements in the array.
So,
$vInput=@_
will put the number of elements in @_ into $vInput, which, naturally, is
always one.
To extract the single argument from the list, do this:
$vInput=shift;
This will take the first (and only) element in @_ and assign it to $vInput.
-----Original Message-----
From: Barry Carroll [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 07, 2001 11:03 AM
To: '[EMAIL PROTECTED]'
Subject: Newbie Question about subroutine
Hi all, i want to have a subroutine for checking user input:
here is a snippet of the code:
print ("Is your Terminal ANSI compliant?\nYes or No, \(y\) or \(n\)?\n");
chomp ($input = <STDIN>);
verifyInput($input);
sub verifyInput
{
# Subroutine to verify input
# Will return the correct value
# and discard bad values
my $vInput = @_;
....
processing in here
....
}
The problem is that I tried entering 'y', 'n', anything!, but no luck.
I found out that $vInput is always getting assigned the numeric value '1'.
The rest of the sub after this is fine, if i could just figure out why
$vInput is being assigned '1'
Any ideas? - Thanks in advance :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]