Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:20:56+00:00 2026-06-17T14:20:56+00:00

I dont really understand how to assign the output of this code to either

  • 0

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";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:20:58+00:00Added an answer on June 17, 2026 at 2:20 pm

    You have two options, depending on how you want to process the data

    Define a variable and append successively to it

    my $from = '';
    ...
    foreach ($pop->Head($i)) {
        $from .= "$_\n" if (/^(From|Subject):/i);
    }
    

    this will give you a large string with all Froms and Subjects together.
    Or you define an array and append to the end of this array

    my @from;
    ...
    foreach ($pop->Head($i)) {
        push @from, $_ if (/^(From|Subject):/i);
    }
    

    this will result in an array, where each element contains one From or Subject line.

    According to Mail::POP3Client, if you want to delete all messages on the POP server

    for my $i (1 .. $count) {
        $pop->Delete($i);
    }
    

    before close should mark all messages for deletion. When you finally close the connection,

    $pop->Close();
    

    all pending deletes will be processed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I dont really understand why this is not working, I am being returned to
I have a big problem because i dont understand how the pointers really work
I just saw this block of code on the Wikipedia article on conditional operators:
I dont really understand about linq, can you help me with this query? SELECT
First sorry, im a really big begginer, i dont really understand something. I am
I dont really understand whats going on and cant see the difference: I'm downloaded
I am currently learning bash programming and dont really understand why the passing argument
I don't really understand why this is happening at all. I'm trying to open
I've spent some time looking over other questions but I dont really understand some
I dont really understand what the last while loop is doing, can someone explain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.