Read the docs for Net::POP3. get returns a reference to an array of lines, not the whole message.
get ( MSGNUM [, FH ] ) Get the message MSGNUM from the remote mailbox. If FH is not given + then get returns a reference to an array which contains the lines of + text read from the server. If FH is given then the lines returned fr +om the server are printed to the filehandle FH.
You just need to search through those lines for the subject.
my $msg = $pop->get($msgnum); for my $line ( @$msg ) { if( $line =~ /^Subject:(.*)/ ) { print "Subject is $1"; last; } }
Or, similarly, use print grep { /^Subject:/ } @$msg;
Update: I should add that when I first read the subject "Problem with $1", my first thought was, "It's not $1,000,000?"
Update: grep doesn't terminate after the first match. List::Util and first is better.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: Problem with $1
by xdg
in thread Problem with $1
by w3b
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |