Not sure i understand the question.
the append works because i did the syntax for it correctly?
open(APPEND,">>testfile") || die print "Can't open testfile: $!\n";
# i state i want to open this filehandle and append >> the data to the file
testfile, otherwise die if
# you can't open testfile
print APPEND "$email\t$action\n"; #to show that file has been added
# then i state i want to Print to the end of that file everything after the
append. which happens to
# be in this case my variables of $email seperated by a tab \t and $action
close APPEND;
# then we close the append just like we would for a read
--
though for some reason my $action variable isn't showing up in the testfile
but the $email does every time.
anyone have any ideas to why $action doesn't get written to the file as well?
#!/usr/bin/perl -w
#Script to add e-mail or domain name to /etc/mail/access file
#if not already present.
# spamadd.pl
#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 "$email\t$action\n"; #to show that file has been added
close APPEND;
}
Thanks,
David Freeman
At 09:27 AM 7/26/01 -0700, you wrote:
>I guess Perl does a buffered write. Soo the un filled buffers may not get
>flushed when the process terminates abruptly as it does in C.
>
>David,
>What made that APPEND to work. If you don't mind can you explain?
>Thanks,
>Venkat
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]