Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Re: HElp on program

by repson (Chaplain)
on Mar 25, 2001 at 12:31 UTC ( #66992=note: print w/replies, xml ) Need Help??

in reply to Re: HElp on program
in thread HElp on program

That code, while it found the main code error, will still sometimes show the error message.

$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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://66992]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (19)
As of 2016-10-21 13:17 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.