in reply to Uninitialized value ?

Try doing this:
#...your code... print "Hello $name,\n "; $secretword = $words{$name} || 'groucho'; #....more code written by you...
what this does is, if the name $name is not in your list, mexnix currently isn't, it automatically assigns "groucho" to $secretword. || is logical OR and you can find it in your perldoc perlop manpage. With this, you can even skip the if ($secretword eq "") { $secretword = "groucho"} stuff, because it already does it for you. My $0.02

__________________________________________________

s mmgfbs nf, nfyojy m,tr yb-zya-zy,s zfzphz,print;
- thanks japhy :)

mexnix.perlmonk.org

Replies are listed 'Best First'.
Re: Re: Uninitialized value ?
by Hofmator (Curate) on Aug 20, 2001 at 18:08 UTC

    and what this also does is bite you back horribly ;-)
    if your $words{$name} evaluates to false, i.e. '' or 0. So better - unless you can outrule those cases: $secretword = defined($words{$name}) ? $words{$name} : 'groucho';

    -- Hofmator