473,725 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extract all hotmail email addresses in a file and store in separatefile

Hi, I have a text file that contents a list of email addresses like
this:

"fo*@yahoo. com"
"to*@hotmail.co m"
"je***@gmail.co m"
"to***@apple.co m"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.

Thanks for any help
Jun 27 '08 #1
45 4439
On Jun 18, 3:33 pm, Dennis <dcho...@gmail. comwrote:
Hi, I have a text file that contents a list of email addresses like
this:

"f...@yahoo.com "
"t...@hotmail.c om"
"je...@gmail.co m"
"to...@apple.co m"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.

Thanks for any help
open INFILE, "<all_emails.tx t";
open HOTMAIL, ">hotmail_only. txt";
open NOTHOTMAIL, ">not_hotmail.t xt";
while(<INFILE>)
{
$_ =~ s/"//g;
print HOTMAIL if $_ =~ /hotmail/i;
print NOTHOTMAIL if $_ != /hotmail/i;
}
close INFILE;
close HOTMAIL;
close NOTHOTMAIL;
Jun 27 '08 #2
On Jun 18, 3:33 pm, Dennis <dcho...@gmail. comwrote:
Hi, I have a text file that contents a list of email addresses like
this:

"f...@yahoo.com "
"t...@hotmail.c om"
"je...@gmail.co m"
"to...@apple.co m"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.

Thanks for any help
open INFILE, "<all_emails.tx t";
open HOTMAIL, ">hotmail_only. txt";
open NOTHOTMAIL, ">not_hotmail.t xt";
while(<INFILE>)
{
$_ =~ s/"//g;
print HOTMAIL if $_ =~ /hotmail/i;
print NOTHOTMAIL if $_ != /hotmail/i;
}
close INFILE;
close HOTMAIL;
close NOTHOTMAIL;
Jun 27 '08 #3
szr
Dennis wrote:
Hi, I have a text file that contents a list of email addresses like
this:

"fo*@yahoo. com"
"to*@hotmail.co m"
"je***@gmail.co m"
"to***@apple.co m"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.

Thanks for any help
To get you started, assuming there are no escaped quotes in between:

while (m!"([^"]+?)"!g) {
if ($1 =~ m!\@hotmail\.co m!) {
... do something with $1
}
else { ... }
}
Or if you are using an array:

foreach my $email (map { s!"([^"]+?)"!$1!g; $_; } @email_list) {
if ($email =~ m!\@hotmail\.co m!) {
...
}
else { ... }
}

(Note, untested, but should give a starting point.)

--
szr
Jun 27 '08 #4
On 18 Jun 2008 at 20:01, cartercc wrote:
On Jun 18, 3:33 pm, Dennis <dcho...@gmail. comwrote:
>I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.

open INFILE, "<all_emails.tx t";
open HOTMAIL, ">hotmail_only. txt";
open NOTHOTMAIL, ">not_hotmail.t xt";
while(<INFILE>)
{
$_ =~ s/"//g;
print HOTMAIL if $_ =~ /hotmail/i;
print NOTHOTMAIL if $_ != /hotmail/i;
}
close INFILE;
close HOTMAIL;
close NOTHOTMAIL;
Firstly, you mean !~ instead of !=. Secondly, referring to $_ all the
time is unnecessary. Try:

open INFILE, "< all_emails.txt" ;
open HOTMAIL, "hotmail_only.t xt";
open NOTHOTMAIL, "not_hotmail.tx t";
while(<INFILE>)
{
s/"//g;
if (/hotmail/i) {
print HOTMAIL;
} else {
print NOTHOTMAIL;
}
}
close INFILE;
close HOTMAIL;
close NOTHOTMAIL;

You might also like to include some error-checking, and avoid
hard-coding the paths.

Jun 27 '08 #5

"Dennis" <dc*****@gmail. comwrote in message
news:e4******** *************** ***********@m36 g2000hse.google groups.com...
Hi, I have a text file that contents a list of email addresses like
this:

"fo*@yahoo. com"
"to*@hotmail.co m"
"je***@gmail.co m"
"to***@apple.co m"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
2. extract out the hotmail addresses and store it into another file.
The hotmail addresses in the original file would be deleted.
You have perl solutions so you won't need this. But was an interesting
little snippet:

/* Sort email addresses (possibly for some nefarious purpose) from file
"input" */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void error(void) {puts("File error"); exit(0);}

int main(void) {
char line[200];
char *p;
int n;

FILE *in,*hot,*notho t;

in=fopen("input ","r");
if (in==0) error();

hot=fopen("hotm ail","w");
if (hot==0) {fclose(in); error();};

nothot=fopen("n othotmail","w") ;
if (nothot==0) {fclose(in); fclose(nothot); error();};

while (1) {

fgets(line,size of(line),in);
if (feof(in)) break;

n=strlen(line);
p=line;
if (line[n-1]='\n') {line[n-1]=0; --n;};
if (n) {
if (line[n-1]='""') {line[n-1]=0; --n;};
if (*p=='"') ++p;

if (strstr(p,"@hot mail.com"))
fprintf(hot,"%s \n",p);
else
fprintf(nothot, "%s\n",p);
};
};

fclose(in);
fclose(hot);
fclose(nothot);

}
--
Bartc
Jun 27 '08 #6
On Wed, 18 Jun 2008 12:33:45 -0700, Dennis wrote:
Hi, I have a
<snip />

Why are you cross-posting this to C and Perl newsgroups?
Rui Maciel
Jun 27 '08 #7
In article <48************ ***********@new s.telepac.pt>,
Rui Maciel <ru********@gma il.comwrote:
>On Wed, 18 Jun 2008 12:33:45 -0700, Dennis wrote:
>Hi, I have a
<snip />

Why are you cross-posting this to C and Perl newsgroups?
Rui Maciel
I assume because he is interested in a C/Perl solution to his problem.

Jun 27 '08 #8
On Jun 18, 8:33*pm, Dennis <dcho...@gmail. comwrote:
1. Strip out the " characters and just leave the email addresses on
each line.
char const *const original = "\"bo*@hotmail. com\"";

char buf[50];

strcpy(buf,orig inal);

buf[strlen(original ) - 1] = 0;

2. extract out the hotmail addresses and store it into another file.

Take the last 12 characters, make them all lowercase, and then compare
with "@hotmail.c om".

I'm not big up on the file access functions, I usually just consult
the reference at dinkumware.com when I want to use them.
Jun 27 '08 #9
Dennis <dc*****@gmail. comwrote:
>Hi, I have a text file that contents a list of email addresses like
this:

"fo*@yahoo.com "
"to*@hotmail.c om"
"je***@gmail.c om"
"to***@apple.c om"

I like to

1. Strip out the " characters and just leave the email addresses on
each line.
'perldoc perlop' and look for either tr/// in combination with the 'd'
option or s/// in combination with the 'g' option. Maybe in combination
with anchoring the RE.

Or you can use substr() to grab anything between the first and last
character, excluding both.
>2. extract out the hotmail addresses
perldoc -f grep
>and store it into another file.
perldoc -f open
>The hotmail addresses in the original file would be deleted.
perldoc -q "delete a line"

jue
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4024
by: Duke of Hazard | last post by:
I have searched without success for a simple script that can read any text html file and extract the email addresses from it. I am not interested in spamming people. I play a sport that requires me to email people when I travel to find partners. Unfortunately only 20% are able to reply because their schedules don't mesh with mine. So this script would be a great way to email 5-10 people from a certain website without having to copy/paste...
4
3050
by: Alexander Vasilevsky | last post by:
How to extract email address from the letter in Outlook Express? http://www.alvas.net - Audio tools for C# and VB.Net developers
4
4278
by: tokcy | last post by:
HI every one, i am using tooltip on click of link and i want like when that tooltip open then background window would be blure(). can anyone help me...
0
8874
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9248
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6695
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4506
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2151
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.