Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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.


Comment on Re: Re: HElp on program
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-07-31 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (255 votes), past polls