$str = 'my cardio workout'; @s = split (/\s/,$str); foreach (@s){ my $new_str = substr ($_,0,1); $new_str = ucfirst ($new_str); $ab .= $new_str; } print "AB is $ab\n";