tekniko has asked for the wisdom of the Perl Monks concerning the following question:

I did not write this and the author is no longer around. The program converts mail spools and is handy in migrating acquired users to our system. It works, but there has to be a better way to write this, especially when many acquisitions (companies) have 50000+ mail users.
#!/bin/perl $infile = "/tmp/mail.aliases"; $outfile = "/tmp/mail.new"; open ( INFILE, $infile ) || die "Can't open $infile: $!\n"; open ( OFILE, ">$outfile" ) || die "Can't open $outfile: $!\n"; while ( <INFILE> ) { s/]//; # attribute 24 type string s/[[]//; s/IDENT://; s/<//; s/>...//; s/`...`//; print OFILE "$_"; } # end while ( <INFILE> )

Replies are listed 'Best First'.
Re: Handling spools
by Fastolfe (Vicar) on Jan 15, 2001 at 19:33 UTC
    Umm.. what does it do? What is this 'attribute 24 type string'? Is it just extracting e-mail addresses from this "IDENT" string?

    Also, looking at the filename, I'm wondering if this is all going into an /etc/mail/aliases type of file, to be hashed into a DB file. If this is the case, and you routinely deal with an excess of 50k users, have you considered hacking up your mail daemon to plug into a real database?

      Actually, we already do that in a 10-node server cluster. This is a utility file that is part of a larger system that one of the former admins wrote. Much of what he wrote was somewhat obfuscated and poorly documented.
Re: Handling spools
by a (Friar) on Jan 16, 2001 at 10:13 UTC
    Huh. So it must take:
    [INDENT:<who@where.com> `abc`]
    and leave who@where.com, plus or minus a few spaces? er:
    s/\[IDENT:\s*<([^>]*)>[^]]*]/$1/
    (what HUBRIS after my dotstar debacle). Probably better if we knew what we were really looking at.

    a