I dont really understand how to assign the output of this code to either a variable for each line of output or just one big block variable. Im using Mail::POP3Client if that helps. The output i am looking to assign a variable to is ” print “$_\n” if /^(From|Subject):/i;”
my $count = $pop->Count();
if ($count < 0) {
print $pop->Message();
} elsif ($count == 0) {
print "no messages\n";
} else {
print "$count messsages\n\n";
for my $i (1 .. $count) {
foreach ($pop->Head($i)) {
print "$_\n" if /^(From|Subject):/i;
}
print "\n";
}
}
You have two options, depending on how you want to process the data
Define a variable and append successively to it
this will give you a large string with all
Froms andSubjects together.Or you define an array and append to the end of this array
this will result in an array, where each element contains one
FromorSubjectline.According to Mail::POP3Client, if you want to delete all messages on the POP server
before close should mark all messages for deletion. When you finally close the connection,
all pending deletes will be processed.