Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
222-3344,joe,300,200,100,increase
222-3344,joe,300,150,150,increase
222-3344,joe,300,550,250,decrease
#!/usr/bin/perl -w #file1 format: name|phone|check amount this mo. #file2 format: name|phone|check amount last mo. open(F1,"file1.txt") || die "cannot open $infilename for reading: $!"; open(F2,"file2.txt") || die "cannot open $infilename for reading: $!"; open(F3,">temp.txt") || die "cannot create $outfilename: $!"; while (<F1>) { ($name,$phone,$check1) = split(/\|/); while (<F2>) { ($name,$phone,$check2) = split(/\|/); $change = $check1 - $check2; if ($check2 > $check1) { $stat = "decrease"; } else { $stat = "increase"; } $_ = join ',', ("$phone","$name","$check1","$check2","$change","$stat" +); print F3 "$_\n"; } } close (F1); close (F2); close (F3);
Edited 2002-04-04 by mirod: changed title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need help with a bug
by dws (Chancellor) on Apr 03, 2002 at 20:16 UTC | |
|
Re: need help with a bug
by Anonymous Monk on Apr 03, 2002 at 20:51 UTC | |
by dws (Chancellor) on Apr 03, 2002 at 21:07 UTC | |
by Zed_Lopez (Chaplain) on Apr 04, 2002 at 00:34 UTC |