Are you looking for something like this?
# UNTESTED! my $county = $query->param('County'); if ( ! $county ) { # no county was passed. # display error page to the user, or ignore the request. } elsif ( ! exists($counties{$county}) ) { # they sent a county, but we have no data for it. # show error page, or just ignore. } else { # we only get here if things went well my $email_county = $counties{$county}->{County}; my $email_region = $counties{$county}->{Region}; my $county_abbrev = $counties{$county}->{Abbrev}; my $email_engr = $counties{$county}->{Engr}; # ...or we can save some space with this, # depending on your needs. It grabs all values # with an "@" and adds them to a list of email # addresses. ...This assumes that you only need # the email addresses and don't care what the # hash key is. my @emails = grep {/\@/} (values %{$counties{$county}}); my $county_abbrev = $counties{$county}->{Abbrev}; # send mails (or whatever) here } Is that what you were looking for? ...Or am I seriously missing the point? Rob -----Original Message----- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 3:20 PM To: [EMAIL PROTECTED] Subject: RE: Hash, query->param help If the user doesn't select a county in the first place, $query->param('County') will be undefined, which means that $counties{$query->param('County')}->{County} will be an error. So I think I need some code to handle this using something like if($query->param('County'){} I'm just stuck. "Hanson, Rob" wrote:> ...only the categories for which they have a value This is probably the easiest way. # this will set the value to '' if the key doesn't exist my $email_county = $counties{$query->param('County')}->{County} || ''; > And how do I wrap this so the user will select a county I'm not sure I understand this one. Can you explain what you mean? Rob -----Original Message----- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:43 PM To: [EMAIL PROTECTED] Subject: Hash, query->param help I'm writing a script to send emails to different locations. Some will receive one email, others 3 or 4. Should each county have all the categories, even if some have an empty value, or only the categories for which they have a value. And how do I wrap this so the user will select a county my %counties = ( Accomack => { Region => '[EMAIL PROTECTED]', County => '', Abbrev => 'ACC', }, Albemarle => { Region => '[EMAIL PROTECTED]', County => '[EMAIL PROTECTED]', Engr => '[EMAIL PROTECTED]', Abbrev => 'ALB', }, Alleghany => { Region => '[EMAIL PROTECTED]', County => '[EMAIL PROTECTED]', Abbrev => 'ALL', ); # Selected County: return EMAIL ADDRESS my $email_county = $counties{$query->param('County')}->{County}; # Selected County: return REGION EMAIL ADDRESS my $email_region = $counties{$query->param('County')}->{Region}; # Selected County: return ABBREVIATION my $county_abbrev = $counties{$query->param('County')}->{Abbrev}; # Selected County: return ENGINEER EMAIL ADDRESS my $email_engr = $counties{$query->param('County')}->{Engr}; #How do I wrap this so they select a county my $counties{$query->param('County')}->{County} if($query->param('County'){} Thanks, GPO --------------------------------- Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs --------------------------------- Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]