my $total_names = "Matthew,Thomas,Peter,Randy,George,Federick"; my ($last_name) = $total_names =~ /,([^,]+)$/; print $last_name if $last_name;