Thanks Steffen, I've have a new input file 'state.txt' and the expected output file 'stateout.txt' and it is becoming more complicated.
I will need to make info from 3 lines into 1 line in some cases. Please help. Thanks James --- On Tue, 3/9/10, steffen johnson <[email protected]> wrote: > From: steffen johnson <[email protected]> > Subject: Re: How to make 2 lines into one > To: "James T." <[email protected]> > Date: Tuesday, March 9, 2010, 8:43 PM > here is a solution I came up with. > See highlights below > > > > ----- Original Message ---- > From: James T. <[email protected]> > To: [email protected] > Sent: Tue, March 9, 2010 4:57:51 PM > Subject: How to make 2 lines into one > > 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+.*)!; > > ##Changes made below=================== > print OUT "$bal"; > undef $bal ; > } > 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
$28,547.94
11/04 Check Printing Charge (includes Delivery
Charges And All Applicable Taxes) $ 41.43
$28,506.51
11/05 Check Card Purchase on 11/04 (Card
#428075378), Avis.com 800-722-4109 TX Ref
#24692168309000493054437 $ 262.82
$28,243.69
11/05 Check Card Purchase on 11/03 (Card
#428075378), Staples 00102665 San Diego
CA Ref #24164078309105126193997 71.07
$28,172.62
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
$28,547.94
11/04 Check Printing Charge (includes Delivery $ 41.43
$28,506.51
11/05 Check Card Purchase on 11/04 (Card $ 262.82
$28,243.69
11/05 Check Card Purchase on 11/03 (Card 71.07
$28,172.62
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
