in reply to Strip first name from string

use warnings; use strict; my $contact = "Firstname Lastname"; #my $contact = "G. Lastname"; my ($Fname,$Lname) = split(' ',$contact); if($Fname =~ /.*\./ ) { print join (' ', ('Mr',$Fname,$Lname)); } else { print join (' ', ('Mr',$Lname)); }

All is well

Replies are listed 'Best First'.
Re^2: Strip first name from string
by hdb (Monsignor) on Jan 29, 2014 at 07:29 UTC

    /.*\./ is equivalent to /\./