LOGFILE
My name is: ?Anthony Perkins
I am an American citizen.
My name is: ?Donte Suarez
I am a Spanish citizen.
My name is: ? lenny Davis
I am an Australian citizen.
My name is: ?allen rigodeau
I am a French citizen.
My name is: ? manuel williams
I am a Mexican citizen.
OUTPUT
First Name - ANTHONY
Last Name - PERKINS
First Name - DONTE
Last Name - SUAREZ
First Name - LENNY
Last Name - DAVIS
First Name - ALLEN
Last Name - RIGODEAU
First Name - MANUEL
Last Name - WILLIAMS
>>>>>>>>>>
SCRIPT
if ( $currline =~ m/My name is\: \?/ )
{
@record = split(/\?/, $currline);
$message = "$record[1]";
@record2 = split(/ /, $message);
$firstname= "$record2[0]";
$lastname = "$record2[1]";
print OUTPUT "First Name -".$firstname;
print OUTPUT "Last Name -".$lastname;
}
>>>>>>>>>>
For the above logfile, my script would be working properly only on Anthony Perkins and allen rigodeau.
But this no longer works if there's a space after the question mark, or when there's more than one space between the first and last name.
Appreciate your advice.
Thanks.