sub alias_to_emailaddress { my ($alias) = @_; #-- e.g. "Bob"; #-- query your DB or start with a hash-lookup for testing... my %alias2email = ( 'BOB' => 'some@email.com', 'TIM' => 'test@cork.com', ); #-- maybe normalise your alias first? my $email = $alias2email{ uc $alias }; #---- now add some error handling... #-- perlhaps you can use a default? # $email //= 'bugreport2self@myhost.com'; #-- throw an exception (catch with 'eval' later) # die "No email-address found for '$alias'!" unless $email; return $email; }