I have a script that queries a database, grabs a bunch of email addresses from it and generates a procmail ruleset for each of them. It also opens a file which contains additional email address and reads them into an array:
open AUTHFILE, "</home/customercare/authorized_users.txt" or die "Can't open file: $!"; foreach my $address (readline AUTHFILE){ chomp($address); next if $address =~ m/^#/gmx; push @email_list, $address; } This seems to have worked at one point but appears to have been changed and doesn't work anymore. The script runs fine with the exception of the part that opens the file and reads the addresses from it. To be clear, it seems to open the file. At least, I'm not getting any errors from the "or die" part. However, when I look for the addresses read in from the file, nothing shows up. Can someone help me shed some light on this? The full script is below. Thanks Mathew #!/usr/bin/perl use strict; use warnings; use DBI; my $message = "You are receiving this message in response to an email you" ." sent to [EMAIL PROTECTED] The email address you sent" ." from is not currently in our records. To have the action you" ." need performed, please call customer care to authenticate."; my $dbh = DBI->connect("dbi:Pg:dbname=xx;host=10.0.2.30", "xxxxx", "xxxxxx"); my @email_list; my $sth; my @fields = qw/email email2 email3/; foreach my $field (@fields){ $sth = $dbh->prepare(" SELECT $field FROM contacts"); $sth->execute; while ((my $line) = $sth->fetchrow()) { if ($line){ if ($line !~ /^\s+$/g){ push @email_list, $line; } } } $sth->finish; } #Read in people from the authorized_users.txt file in the customercare directory #These are email addresses that are not in OSS but are allowed to create tickets open AUTHFILE, "</home/customercare/authorized_users.txt"; while (<AUTHFILE>) { chomp; next if $_ =~ m/^#/gmx; push @email_list, $_; } print(" #This File is generated by proclmailgen.pl and should not be edited directly. #It will be overwritten the next time the cron job runs. VERBOSE=off PMDIR=\$HOME/.procmail DEFAULT=/var/spool/mail/customercare LOGFILE=\$PMDIR/log LOCKFILE # removes any preexisting lockfile LOG=\`lockfile \$DEFAULT\$LOCKEXT\` TRAP=\"rm -f \$DEFAULT\$LOCKEXT\" "); printf(" :0 E * ^From.*([EMAIL PROTECTED]) badmail "); printf(" :0 E * ^Return-Path.*([EMAIL PROTECTED]) badmail "); printf(" :0 E * ^X-Loop.*([EMAIL PROTECTED]) badmail "); for my $address (@email_list){ $address =~ s/ //g; printf(" :0 E * ^From.*(%s) | /usr/local/rt-3.6.0/bin/rt-mailgate --queue customercare --action correspond --url https://rt.company.com/ " , ($address)); } printf(" :0 E * ^From(.*) | (formail -r -A\"X-Loop: [EMAIL PROTECTED]" ; echo \"%s\") | /usr/sbin/sendmail -f [EMAIL PROTECTED] -t " , ($message)); -- Keep up with me and what I'm up to: http://theillien.blogspot.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/