Ask a Question related to PERL Beginners, Design and Development.
-
Perldiscuss - Perl Newsgroups And Mailing Lists #1
IO File Problems
hi there,
couse of my missing skills with filehandling i would be happy if you
provide me help.
this is my problem:
1) I´m getting a list of email adresses (strings) from a database into an
array - o.k. no problem ...
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]
0=O*@ms.com
1=Oexample@loopback.eu
2=Ogot@it.at
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 calc to the digit
number of the last entry +1.
how can i handle this?
i would be happy if you provide me some functions to search the string in
the file and filter spec. chars from a line out.
sorry 4 my bad english but i am from austria :)
best regards,
lukas
Perldiscuss - Perl Newsgroups And Mailing Lists Guest
-
LCK file problems
I have a site i try to edit with contribute 1.0. But when i publish errormessage says "another user has removed your lock". I am the only user on... -
PDF File Problems
I have been putting out a newsletter for a woodworking club I belong to. I have been using Indesign to create the newsletter and then export it to a... -
Tar & Un Tar File problems
Hi all, I am doing Tar for a set of files using the command : tar cf - sri* | compress > x.tar When i try to untar using the following... -
Problems with File Uploads
Hello, I've written the following sourcecode: <form action="test.php" method="POST" enctype="multipart/form-data"> <input type="file"... -
File problems
Hi, I am having a hell of a time with this. Whenever I think it's working, something else screws up. There obviously has to be a better way to do... -
Perldiscuss - Perl Newsgroups And Mailing Lists #2
IO File Problems
hi there,
couse of my missing skills with filehandling i would be happy if you
provide me help.
this is my problem:
1) I´m getting a list of email adresses (strings) from a database into an
array - o.k. no problem ...
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]
0=O*@ms.com
1=Oexample@loopback.eu
2=Ogot@it.at
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 calc to the digit
number of the last entry +1.
how can i handle this?
i would be happy if you provide me some functions to search the string in
the file and filter spec. chars from a line out.
sorry 4 my bad english but i am from austria :)
best regards,
lukas
Perldiscuss - Perl Newsgroups And Mailing Lists Guest
-
Wolf Blaum #3
Re: IO File Problems
> hi there,
hi | servus,
I assume @emails to be your array.> 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]
> 0=O*@ms.com
> 1=Oexample@loopback.eu
> 2=Ogot@it.at
>
> 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
#!/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.
I didnt get what you want here - sorry.> calc to the digit
> number of the last entry +1.
Nevermind, great skiing over there! Send me a mail in german (or austrian:-)> sorry 4 my bad english but i am from austria :)
if you need further help.
Hope thats a start, Wolf
Wolf Blaum Guest



Reply With Quote

