elsif ($last =~ m/([A-Za-z\'\-]+)/) { $surname = $1; } #### elsif($last =~ m/(\w+)\s+(\w+)/) { # note the + here. $surname = join(' ', $1, $2); # note change to $2 } elsif($last =~ /([A-Za-z\'\-]+)/) { $surname = $1; }