"John W. Krahn" wrote:
> 
> I would read the data file first and then modify the master file:
> 
> my $fname = shift || 'scanned.file';
> 
> open DATA, $fname or die "Could not open $fname: $!";
> my %data = map /^([^,]+),\s*(\d+)/, <DATA>

Should be a semicolon at the end.

my %data = map /^([^,]+),\s*(\d+)/, <DATA>;


> close DATA;
> 
> open Master, 'master.file' or die "Could not open master.file: $!";
> open NewMasterList, '>>Results.file' or die "Could not write
> Results.file: $!";
> 
> while ( <Master> ) {
>     # assumes that you want to preserve the spacing
>     my ( $key, $space, $val ) = /^([^,]+),(\s*)(\d+)/;
>     if ( exists $data{ $key } ) {
>         $_ = "$key,$space" . $val - $data{ $key } . "\n";
>         }
>     # print results
>     print NewMasterList;
>     }
> 
> close Master;
> close NewMasterList;
> exit 0;
> 
> __END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to