Pay particular attention the comments. You haven't made your particular situtation (file formats, etc.) completely known, so I've made some assumptions.
At the very least, this should provide a good starting point. Good luck!
#!/usr/bin/perl -w # # note: this assumes that each line in email_list.txt contains only # one email address use strict; open (EMAIL, "< email_list.txt") || die "cannot open email_list.txt: $ +!"; #open email address file while (my $email_address = <EMAIL>) { chomp($email_address); open (OUT, ">$email_address.txt") || die "cannot open $email_addre +ss: $!"; open (JOHN, "< john.txt") || die "cannot open john.txt: $!"; while (my $main_input = <JOHN>) { chomp($main_input); if ($main_input =~ /email=/) { # matching email addresses is tricky, so YMMV on the # + following $main_input =~ s/([a-zA-Z0-9]{3})\@([a-zA-Z0-9\.\-]*)\ +%?.*$/$email_address/; } print OUT "$main_input\n"; } close JOHN; close OUT; } close EMAIL;
Update: Added close EMAIL;
If things get any worse, I'll have to ask you to stop helping me.
In reply to (shockme) Re: Search and replace
by shockme
in thread Search and replace
by rscott212
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |