> hi there,
hi | servus,
> 2) now i have to merge this strings with strings from a file. in this file
> there are many configuration sections.
> the section i need looks like this:
>
> [WHITELIST]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> so i need to get all adresse under the [whitelist] tag into an array and
> merge them with my other array.
>
> i need to move the filepointer unter the tag - than cut the digit number
> and the "=" out - put the email adress in a array and
I assume @emails to be your array.
#!/usr/bin/perl
use strict;
use warnings;
my @emails=get_db_emails;
open (FH, "<whitelist.txt") or die "Cant open whitelist.txt: $!";
while (<FH>){
next unless (/\[WHITELIST\]/);
my $inlist=1;
while ($inlist){
chomp ($_=<FH>);
if (/^\d+=(.*)/) {push @emails, $1;}
else {$in_list=0;}
}
}
Yes, this is very dirty and only works if the whitelist.txt file looks like
you showed - however, it can hold multiple [WHITELIST] sections.
A section is assumed to end on the first line found that doesent hold the
digits=email pair.
Note that you shouldnt try to verify email syntax yourself (unless you want to
spend weeks implementing the rfc822 and related).There is a Email::Valid
modul at CPAN that does not only check the syntaxx but also if there is a MX
server in that domain accepting email.
> calc to the digit
> number of the last entry +1.
I didnt get what you want here - sorry.
> sorry 4 my bad english but i am from austria :)
Nevermind, great skiing over there! Send me a mail in german (or austrian:-)
if you need further help.
Hope thats a start, Wolf
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>