Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. Problems with File Uploads
      Hello, I've written the following sourcecode: <form action="test.php" method="POST" enctype="multipart/form-data"> <input type="file"...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default Re: IO File Problems

    > 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]
    > 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
    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


    Wolf Blaum Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139