in reply to Re: HElp on program
in thread HElp on program
$secretword=$words{$name}; if ($secretword eq ""){ $secretword="stupid"; }
If $name is not found in the hash %words, then $secretword will be undefined and will produce the error mentioned when used as if defined. If you however test for the definedness of $secretword you will be closer to the original aim.
if (defined $secretword) { $secretword = 'stupid'; }
In perl style I'd probably write:
$secretword = $words{$name} || 'stupid';
But that is a matter of choice.
|
|---|