Unsure. I always run with warnings and I was told it was better to use $_[0] vs @_ . The message there was
Scalar value @_[0] better written as $_[0] On the second it comes back with msg: Scalar value @answers[$i] better written as $answers[$i] So I did. Wags ;) -----Original Message----- From: Steven M. Klass [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 14:09 To: Wagner-David; [EMAIL PROTECTED] Subject: Re: More help with my function Hi all, Doh!! It must be MONDAY!! I am such an IDIOT!! Couple of questions. How did changing $prompt [@_[0]] to $prompt $_[0] fix it? I mean why didn't $_[0] put the prompt. Let me guess shift removed it from the stack.. I know that if I want the first variable of @answers I can call it with $answer[0], but why doesn't @answers[0] work? Thanks so much On Friday 15 February 2002 02:49 pm, Wagner-David wrote: > Uncertain what you are trying to get from the list: > > I changed print "$prompt [@_[0]]"; to print "$prompt $_[0]"; > > and if ( $response eq $answers ){ to if ( $response eq $answers[$i] ){ > > It ran without any warnings and after I gave correct answer, it quit. > > Wags ;) > -----Original Message----- > From: Steven M. Klass [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 15, 2002 13:26 > To: [EMAIL PROTECTED] > Subject: More help with my function > > > Hi all, > > Here is a simple script that I am having a heck of a time with. I think it > will become apparent what I'm trying to do. Ask a question and validate > the answer. > > &AskQuestion("Enter the hierarchical mode", my @hier = qw/inquiry smart > yes/); > > sub AskQuestion { > my $prompt = shift; > my @answers = @_; > my $response; > while ( ! $response ) { > print "$prompt [@_[0]]"; > $response = <STDIN>; > chomp $response; > if ( $response eq "" ) { > $response = @answers > } > if ( $response eq "?") { > $response = ""; > print "Valid answers are: \n"; > print "@answers\n"; > } > print "\n"; > > my $match; > for ( my $i = 0; $i < @answers ; $i++ ){ > if ( $response eq $answers ){ > $match = "true"; > return $response; > } > } > if ( ! $match ){ $response = "";} > } > } > > I think it must be friday or something, but could someone help me clean > this up. I want something simple, and I think I have over-engineered this. > Any help is appreciated! > > Thanks so much. I love this list!:) -- Steven M. Klass Physical Design Manager National Semiconductor Corp 7400 W. Detroit Street Suite 170 Chandler AZ 85226 Ph:480-753-2503 Fax:480-705-6407 [EMAIL PROTECTED] http://www.nsc.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]