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"
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"