Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using a script which processes emails from paypals ipn and adds the sender to a mailing list. In the body of the email that is being sent there is a "first_name" field we want to use this to get the senders name. The following bit of code tries to get the name (this is where i'm stuck, I'm assuming its trying to get the name from the 'from name' in the email address) but its putting the senders email in the name field, can I make it get the name from the "first_name" field in the body of the email?

thanks

Mike
________________________________

# check for name spaces

$spos = index($thestr,' ');
if($spos>=0) { $justmail = ''; } else { $justmail = 1; }

if($justmail ne 1){
# get name
$name = substr($thestr,0,$lbpos-14);
# strip quotes
$name =~ s/\"//g;

$spos = index($name,' ');
if($spos>=0){
$fn = substr($name,0,$spos);
$ln = substr($name,$spos+1,length($name)-$spos-1);
} else {
$fn = $name; $ln = '';
}
}

Replies are listed 'Best First'.
Re: get name field from paypal ipn
by Anonymous Monk on May 20, 2009 at 09:18 UTC
    What does the input (the email) look like?
        here's how (replace '01' with 'first_name'):
        $_ = join q,,,map chr, 33 .. 126; print "$_\n"; print substr($_, index($_,'01'),64),"\n"; __END__