Bad koolgirl. I gave you nice clean code and you nastised it. Here are a few guidelines to help make it nice again:
and the niceised code:
use strict; use warnings; my $dir = 'F:\project_files'; my $fInName = 'carson_county_abstract.txt'; my $fOutName = 'cars_abstract.txt'; my %docs; opendir my $dirScan, $dir or die "Failed to open $dir: $!\n"; while (defined(my $entry = readdir $dirScan)) { next if $entry !~ /docs(.*)/; my $currParcel = $1; my $filePath = "$dir\\$entry"; open my $inFile, '<', $filePath or die "Can't open $filePath: $!\n +"; while (defined (my $line = <$inFile>)) { chomp $line; $docs{$line} = $currParcel; } close $inFile; } open my $fIn, '<', $fInName or die "Failed to open $fInName: $!"; open my $fOut, '<', $fOutName or die "Failed to create $fOutName: $!"; while (defined (my $line = <$fIn>)) { next if $line !~ /Document #: ([0-9]*)(.*)/; print $docs{$1} . "\n"; print $fOut "parcel# $docs{$1} doc num $1 $2\n"; } close $fOut or die "Error closing $fOut: $!\n";
To fix your duplication problem you might want to use another hash to check for duplicate document/parcel pairs.
Ok, and if you don't understand stuff find a friendly web site dedicated to the area and ask for clarification ;).
In reply to Re^2: Matching and combining two text files
by GrandFather
in thread Matching and combining two text files
by koolgirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |