Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-02-22 23:48 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (300 votes). Check out past polls.