3 my $ip_file = "$ENV{HOME}/.spam_ips";
5 #####################################################################
6 # load a data structure from a file (as saved with SaveStructure)
10 my $contents = FileLoad($f);
11 return eval "$contents";
18 #####################################################################
19 # read a file into a string
22 my($filename) = shift;
24 open(INPUTFILE, $filename) || return undef;
25 my($saved_delim) = $/;
27 my($data) = <INPUTFILE>;
33 #####################################################################
34 # write a string into a file
37 my($filename) = shift;
40 open(FILE, ">$filename") || die "can't open $filename";
45 #####################################################################
46 # save a data structure into a file
49 my($filename) = shift;
51 FileSave($filename, Dumper($v));
60 while (my $line = <>) {
61 if ($line =~ /^Received: from .*?\[([\d\.]+)\]/) {
67 if ($ip eq "127.0.0.1") {
72 my $ips = LoadStructure($ip_file);
74 SaveStructure($ip_file, $ips);