Are you closing the APPEND file at the end of the process?
-----Original Message-----
From: David Freeman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 25, 2001 3:51 PM
To: [EMAIL PROTECTED]
Subject: appending to file?
ok last question on this script for today. According to the book i should
be able to do
open(Filehandle, ">> Filename") || die "Can't Open Filename $!\n";
print Filehandle "just appended to the end of filename. \n";
and anything after the filehandle in the second line would be what is
appended to Filename. I've made a test file to try and append to from my
script but it doesn't ever show up in that file. I think maybe my While
statement is forever going, but don't know how to break free and move on to
the next lines of the script.
Thanks
#!/usr/bin/perl -w
#Script to add e-mail or domain name to /etc/mail/access file
#if not already present.
#use strict;
#use warnings;
my $email;
my $action;
my $newarray;
open(NAMES,"/etc/mail/access") || die "Can't open access: $!\n";
while (<NAMES>){
( $email, $action )= split(/\t/);
$newarray{$email} = $action;
}
close NAMES;
while(1){
print "Look for what domain in spam filter? ";
chomp($email=<STDIN>);
last unless $email;
if( exists $newarray{$email} ){
print $newarray{$email}, "\n";
}else{
print "How you wanna handle this one? ";
my $action;
chomp( $action = <STDIN> );
$newarray{$email} = $action;
}
open(APPEND,">>testfile") || die print "Can't open testfile: $!\n";
#line above to eventually open /etc/mail/access and append $email & $action
#to file.
print APPEND "test of append function. \n"; #to show that file has been
added
}
David M.R. Freeman
webmaster sysadmin for MMP, Inc.
web: www.woodfreeman.com
e-mail: [EMAIL PROTECTED]
phone: (253) 564-5902
fax: (253) 565-1811