|  | extract all hotmail email addresses in a file and store in s |  | |
| | | Dennis |  |
| Posted: Wed Jun 18, 2008 7:33 pm Post subject: extract all hotmail email addresses in a file and store in s |  |
Hi, I have a text file that contents a list of email addresses like this:
"foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com"
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 |
| |
| | | szr |  |
| Posted: Wed Jun 18, 2008 7:33 pm Post subject: Re: extract all hotmail email addresses in a file and store |  |
Dennis wrote:
| Quote: | Hi, I have a text file that contents a list of email addresses like this:
"foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com"
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\.com!) { ... 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\.com!) { ... } else { ... } }
(Note, untested, but should give a starting point.)
-- szr |
| |
| | | Harald van Dijk |  |
| Posted: Wed Jun 18, 2008 7:33 pm Post subject: Re: Problems using getaddrinfo and friends using c99 standar |  |
On Wed, 18 Jun 2008 20:17:21 +0000, Antoninus Twink wrote:
| Quote: | On 18 Jun 2008 at 18:54, Nathan wrote: I'm trying to do some network programming, but when I use 'struct addrinfo' or getaddrinfo, I see errors: [snip] ipv6_test.c:34: warning: implicit declaration of function `getaddrinfo' [snip] ipv6_test.c:56: warning: implicit declaration of function `gai_strerror' [snip] ipv6_test.c:77: warning: implicit declaration of function `freeaddrinfo'
You're probably not including the reqired headers. Try
#include <sys/types.h #include <sys/socket.h #include <netdb.h
|
The OP probably is including the required headers, or the compiler would also have complained without the --std-c99 option. The answer is simply that getaddrinfo is not a C99 function, and is therefore not declared by the library when asking for a C99 implementation. |
| |
| | | Bartc |  |
| Posted: Wed Jun 18, 2008 7:33 pm Post subject: Re: extract all hotmail email addresses in a file and store |  |
| |  | |
"Dennis" <dchou4u@gmail.com> wrote in message news:e4359263-995d-4b1a-8865-9a97eceb7dc2@m36g2000hse.googlegroups.com...
| Quote: | Hi, I have a text file that contents a list of email addresses like this:
"foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com"
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,*nothot;
in=fopen("input","r"); if (in==0) error();
hot=fopen("hotmail","w"); if (hot==0) {fclose(in); error();};
nothot=fopen("nothotmail","w"); if (nothot==0) {fclose(in); fclose(nothot); error();};
while (1) {
fgets(line,sizeof(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,"@hotmail.com")) fprintf(hot,"%s\n",p); else fprintf(nothot,"%s\n",p); }; };
fclose(in); fclose(hot); fclose(nothot);
}
-- Bartc |
| |
| | | Bill Cunningham |  |
| Posted: Wed Jun 18, 2008 7:33 pm Post subject: Re: seg fault |  |
"Joachim Schmitz" <nospam.jojo@schmitz-digital.de> wrote in message news:g3boc5$1bn$1@online.de...
| Quote: | gcc-3.4.6 And you are aware that gcc (no matter what version) is not a fully conforming C99 compiler? Not even with --std=c99.
|
No I didn't know that. I guess you learn something new everyday.
Bill
---- "You big dummy"
--Fred Sanford
|
| |
| | | cartercc |  |
| Posted: Wed Jun 18, 2008 8:01 pm Post subject: Re: extract all hotmail email addresses in a file and store |  |
On Jun 18, 3:33 pm, Dennis <dcho...@gmail.com> wrote:
| Quote: | Hi, I have a text file that contents a list of email addresses like this:
"f...@yahoo.com" "t...@hotmail.com" "je...@gmail.com" "to...@apple.com"
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.txt"; open HOTMAIL, ">hotmail_only.txt"; open NOTHOTMAIL, ">not_hotmail.txt"; while(<INFILE>) { $_ =~ s/"//g; print HOTMAIL if $_ =~ /hotmail/i; print NOTHOTMAIL if $_ != /hotmail/i; } close INFILE; close HOTMAIL; close NOTHOTMAIL; |
| |
| | | CBFalconer |  |
| Posted: Wed Jun 18, 2008 8:28 pm Post subject: Re: Reading .ini files in ANSI C |  |
Guillaume Dargaud wrote:
| Quote: | anybody knows if there's some ANSI-C conformant code around that can read Windows-style .ini files ? I don't care about writing to it but I need to be able to read it from various OSs, so there shouldn't be any Windows includes.
|
No problem. They are really just text files, obeying some formatting rules. fopen, getc, and fclose can access them all.
-- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section.
** Posted from LINK ** |
| |
| | | Antoninus Twink |  |
| Posted: Wed Jun 18, 2008 9:17 pm Post subject: Re: Problems using getaddrinfo and friends using c99 standar |  |
On 18 Jun 2008 at 20:37, Harald van Dijk wrote:
| Quote: | The OP probably is including the required headers, or the compiler would also have complained without the --std-c99 option. The answer is simply that getaddrinfo is not a C99 function, and is therefore not declared by the library when asking for a C99 implementation.
|
I think you're right. That seems like a terrible misfeature of gcc. If I have a C program and I include a POSIX header, I damn well want the functions from that header, in just the same way as if I include my own header file then I want access to those functions, without the compiler getting all holier-than-thou and telling me my functions aren't mentioned in the C standard.
One solution is to add -D_POSIX_C_SOURCE=200112L as a command-line option. |
| |
| | | Tomás Ó hÉilidhe |  |
| Posted: Wed Jun 18, 2008 9:52 pm Post subject: Re: Bitwise operators |  |
| |  | |
On Jun 18, 10:32 pm, Santhosh <santhoshvenkat1...@gmail.com> wrote:
| Quote: | If we have n = 34
Result has to be 3,4
|
Ever heard of mathematics? Number systems?
A typical number system consists of: 1) Radix = the amount of different symbols 2) The actual pictures that represent the symbols
Let's take the "octal" number system: 1) Radix = 8 2) Symbols = 0 1 2 3 4 5 6 7
If you want to represent a number that is greater than or equal to radix, then you need more than one digit. So in octal, the number eight is written as: 10 And nine is written as: 11
Here, the "11" is equal to: 1 multiplied by (8 to the power of 1) +1 multiplied by (8 to the power of 0)
Try another octal number: 2763 2 multiplied by (8 to the power of 3) +7 multiplied by (8 to the power of 2) +6 multiplied by (8 to the power of 1) +3 multiplied by (8 to the power of 0)
Try think now, if you had a number in decimal such as 34, then what would you do to it to get the first digit and the second digit? I'll give you a clue, it involves using the radix, i.e. 10, in conjunction with a mathematical operation such as division. |
| |
| | | Antoninus Twink |  |
| Posted: Wed Jun 18, 2008 10:19 pm Post subject: Re: Bitwise operators |  |
On 18 Jun 2008 at 22:09, Walter Roberson wrote:
| Quote: | Turing equivilence only works for "sufficiently powerful" computation systems, and the four operators ~ ^ & | alone are not "sufficiently powerful" for to be able to generate any arbitrary algorithm.
|
They are sufficiently powerful to generate all the operations performed by your favorite ALU. |
| |
| Page 1 of 5 .:. Goto page 1, 2, 3, 4, 5 Next | |
|
|