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 8881271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:18:40+00:00 2026-06-14T20:18:40+00:00

I have a .txt file with many emails including headers. I’m just wondering how

  • 0

I have a .txt file with many emails including headers. I’m just wondering how I would use perl to find out how many occurrences of the same email address are found in this text file?
Would it involve regular expressions?

  • 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-14T20:18:41+00:00Added an answer on June 14, 2026 at 8:18 pm

    How about this script:

    #!/usr/bin/perl
    
    use strict;
    use Data::Dumper;
    
    my @email_list = ();
    my %count;
    
    while (my $line = <>) {
        foreach my $email (split /\s+/, $line) {
            if ( $email =~ /^[-\w.]+@([a-z0-9][a-z-0-9]+\.)+[a-z]{2,4}$/i ) {
    
                push(@email_list,$email);
            }
        }
    }
    
    print "Total Email Count: ".scalar(@email_list)."\n\n";
    $count{$_}++ for @email_list;
    print Dumper(\%count);
    

    Save it to a file such as email.pl and make sure it executable chmod +x email.pl.

    ./email.pl file.txt

    It will print the total number of email addresses found and count per email address.

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

Sidebar

Related Questions

I have this file file.txt which I want to split into many smaller ones.
i have a txt file which contains many chinese characters, and the txt file
So, I have a text file (data.txt), It's a story, so just sentence after
I have opened a .txt file many times using the C language's file handling
I have a txt file containing many records, each record has 5 rows and
I have a big txt file ,with many strings ,say string-I-want-to-change,now I need to
I have a txt file that has many rows of lines I want to
i have a .txt file containing data like: He: 22.1 Ar: 21.1 K: 1.22
I have a txt file that is generated on the server and contains newlines.
I have a .txt file with content(see first image) I need the content in

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.