Thanks for replies, I need to explain some more because
I think my code might be better ignored! 

The files are inventory balances for each day.
I need to check todays file against the old file (yesterdays)
and:
Add deleted stuff to the new file (to which I will add
a balance of zero).
The new file will then become a revised version of todays.

The code I'm having difficulty writing is how to compare one
file with another by matching fields unique to both and
adding fields not matched. theoretical example:

old equals
a 10:10
b 10:10
c 15:10
d 12:10

today equals
a 09
b 05
d 10
e 50
f 50

new wants to be 
a 10:10:09
b 10:10:05
d 12:10:10
e 00:00:50
f 00:00:50
c 15:10:00

Here's some of my code for the subroutine comparing
old against today. It is way off as it maintains it's
place in the today file.
I need it to check the whole of the NEW file each time and
if found: 
   exit the loop with variables containing data
   from that line to add to new file.
if not found:
   add $a1 (plus $a2,3,etc) to new file. 
 
Please note that there are other substitutions made $a2, $a3, etc,
which are not part of the if but will need to be available to
add to NEW.

patience and observations appreciated.
jpf


while (<OLD>) {
   # read in old file line at a time
   chomp;
   for ($a1 = substr($_,1,12))  {s/^\s+//;s/\s+$//}
   while (<TODAY>) {
      # find line in new file
      $found=0;
      for ($b1 = substr($_,0,12))  {s/^\s+//;s/\s+$//}
      if ($a1 eq $b1) {
         $found=1;
         print NEW "$a1\n";
         last
      }
      if ($found eq 0) {print NEW "*** $b1\n";}
      last
   }
}
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to