Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl help? Anyone? I'm a Perl newb.

Status
Not open for further replies.

ponetguy2

MIS
Aug 28, 2002
442
US
Hello All,

Please forgive me if this is a stupid question. I'm new to Perl and I'm not familiar w/ the err messages. I'm trying to follow O'Reilly's Learning Perl. I pretty much copied the sample script, by I'm getting an error message. Can someone please explain?

Here is the script:


#!/usr/bin/perl -w
%words = qw (
fred camel
barney llama
betty alpaca
wilma alpaca
);
print "What is your name? ";
$name = <STDIN>;
chomp ($name);
if ($name eq "Randal") {
print "Hello, Randal! How good of you to be here!\n";
} else {
print "Hello, $name!\n"; # ordinary greeting
$secretword = $words {$name}; # get the secret word
print "What is the secret word? ";
$guess = <STDIN>;
chomp ($guess);
while ($guess ne $secretword) {
print "Wrong, try again. What is the secret word? ";
$guess = <STDIN>;
chomp ($guess);
}
}

Here is the message :

sun3# ./hello_world2.pl
What is your name? eric
Hello, eric!
What is the secret word? camel
Use of uninitialized value in string ne at ./hello_world2.pl line 19, <STDIN> line 2.
Wrong, try again. What is the secret word?

Please explain.

"Not all OSs suck, it's just that some OSs suck worse than others"


 
There is a perl forum, use that instead of this forum.

There is no login eric! It needs to test the existence of the name in the table.

Try one of the existing values like 'fred'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top