Hi All,

I want to read from an input file 'state.txt' and create a file like 
'stateout.txt'.
Basically I want to print the daily balance into the same line as the others.
Can anybbody help please?
Thanks
James

open OUT,">stateout";
while (<>)
 { 
   chomp;
   next unless ( m!^\s+\d+! || m!^\s+\$\d+! );
   
   if ( m!^\s+\d+! )
    {
      ($date,$des,$ref,$deb,$credit) = split (/\s\s\s+/);
      print OUT "\n" if ( $bal =~ m!^\s*$! );
         print OUT "$date\t$des\t$ref\t$deb\t$credit\t";
    }
   elsif ( m!\s\s+\$\d+! )
    {    
      ($bal) =  m!(\$\d+.*)!;
      print OUT "$bal\n"; 
  }
  close(OUT);


      
 
 Posted  Description                     Reference #           Debits          
Credits        Daily Balance
 
 10/16   Deposit                                                               
$ 50.00 
                                                                                
                  $50.00
 
 10/24   Deposit                                                               
$ 22,000.00 
                                                                                
                  $22,050.00
 
 10/27   Deposit                                                               
$ 17,000.00 
 10/27   Deposit                                                                
 22,000.00 
 10/27   Deposit                                                                
 22,000.00 
                                                                                
                   $83,050.00 
 10/29   Check # 1001                                                         $ 
22,000.00 
                                                                                
                   $61,050.00 
 10/31   Check # 1004                                                         $ 
22,000.00 
                                                                                
                   $39,050.00 
 11/03   Deposit                                                              $ 
2,700.00 
 11/03   Check # 1005                                                         $ 
12,196.06 
 11/03   Check # 1006                                                           
 1,006.00 
                                                                                
         
 
 Posted  Description                     Reference #           Debits          
Credits        Daily Balance
 
 10/16   Deposit                                                               
$ 50.00        $50.00                                                           
                                      
 10/24   Deposit                                                               
$ 22,000.00     $22,050.00                                                      
                                            
 10/27   Deposit                                                               
$ 17,000.00
 10/27   Deposit                                                                
 22,000.00
 10/27   Deposit                                                                
 22,000.00     $83,050.00                                                       
                                             
 10/29   Check # 1001                                                         $ 
22,000.00      $61,050.00                                                       
                                            
 10/31   Check # 1004                                                         $ 
22,000.00      $39,050.00                                                       
                                            
 11/03   Deposit                                                              $ 
2,700.00 
 11/03   Check # 1005                                                         $ 
12,196.06     1,006.00                                                          
                                       
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to