To: boss@wherever
Subject:Accounts
Dear Boss,
[[[
my($message="");
my($File)=substr($file,0,rindex($file,":"));
$File=$File.":accounts";
open(IN,$File) or die($!);
my(@xsc)=;close(IN);
my($xx,%xoose);
my($xlank)="              ";
for($xx=0;$xx<=$#xsc;$xx++){
  my(@xmp)=split('\t',$xsc[$xx]);
  chomp(@xmp);
  $xoose{$xmp[0]}=substr($xmp[0].$xlank,0,10).substr($xmp[1].$xlank,0,16).substr($xmp[5].$xlank,6);
  }
foreach $xx (sort(keys(%xoose))){
  my($xamount)=substr($xoose{$xx},26);
  if($xamount>999) {$message.=$xoose{$xx};}
  }
my(@dt)=localtime();$dt[4]++;$dt[5]+=1900;
save_as("balances".$dt[4]."/".$dt[3]."/".$dt[5]);
if($message ne "") {
  return("Here is a list of the accounts with big balances.\n".$message."\n");
  }
else {return("All accounts have balances of less than \$1,000.\n");}
]]]

Me



****************************

This is a pmail message to solve the following problem. Every morning the accounting department emails you a tab separated file containing data on the accounts for your department. Your boss wants you to email him a list of all the accounts with a balance of more than $999.

You save the data in a file called 'accounts' in the same directory as this message. Then you just pmail the message and the information goes off to your boss and you can get on with other stuff.

You might however like a record that you actually did this. The function 'save_as' does this for you by saving a copy of the actual message and adding the date/time stamp to it rather than to this script. If you are really paranoid you might want to say

my($text)=join("",@xsc);
save_as("balances".$dt[4]."/".$dt[3]."/".$dt[5],$text);
which will also add an !END! and then contents of the 'accounts' file that you used to compose the message.

Here are the steps