sub format_name_for_AD { my $empl_name = shift; # $empl_name has the form "Last, First" my ($last, $first) = $empl_name=~/^([^,]+), (.+)/ or return undef; return uc(substr($first, 0, 1)) . ucfirst($last); } for ('Smith, John', 'Wall, Larry', 'Perlis, Alan', 'Ritchie, Dennis') { print format_name_for_AD($_), "\n"; }