Hi, I have two files FILE-1 & FILE-2 in given format.
FILE-1
CLAYCOUNTY;Wood;statecode=FL CLAYCOUNTY;Wood;statecode=FL SUWANNEECOUNTY;Wood;statecode=FL SUWANNEECOUNTY;Wood;statecode=TX SUWANNEECOUNTY;Wood;statecode=TX SUWANNEECOUNTY;Wood;statecode=TX NASSAUCOUNTY;Wood;statecode=UT
Step 1: Parse file FILE-1 with search key "Wood" and store the file columns into hash. I want to use 2nd and 3rd column and put it into a hash. with the 2nd column being the keys and 1st column being the distinct values.
e.g. for Key "Wood" values are
CLAYCOUNTY,
SUWANNEECOUNTY,
NASSAUCOUNTY
open (my $fh, "<", $file) or die "Can't open the file $file: "; while (<$fh>) { my $line = $_ if /\bWood\b/; chomp ($line); last if !$line; %hash2 = (%hash2 , (split(/;/, $line)),[1,0]); } print Dumper \%hash2;
FILE-2 Format as below
119736;Residential;CLAYCOUNTY 448094;Residential;CLAYCOUNTY 206893;Residential;CLAYCOUNTY 333743;Residential;CLAYCOUNTY 172534;Residential;CLAYCOUNTY 785275;Residential;CLAYCOUNTY 995932;Residential;CLAYCOUNTY 223488;Residential;CLAYCOUNTY 433512;Residential;CLAYCOUNTY 640802;Residential;SUWANNEECOUNTY 403866;Residential;SUWANNEECOUNTY 828788;Residential;SUWANNEECOUNTY 751490;Residential;SUWANNEECOUNTY 972562;Residential;SUWANNEECOUNTY 367541;Residential;SUWANNEECOUNTY 481360;Residential;SUWANNEECOUNTY 920232;Residential;NASSAUCOUNTY 727659;Residential;NASSAUCOUNTY 471817;Residential;NASSAUCOUNTY 983043;Residential;NASSAUCOUNTY 578286;Residential;NASSAUCOUNTY
Step 2: From above step take the column 1 distict value if FILE-1 and find all the values in column 1 of my FILE-2 and write them to output file.
In FILE-2 I want to use the 3rd and 1st column, with the 3rd column being key and 1st column being the values.
e.g. For key
CLAYCOUNTY values are 119736, 448094, 206893, 333743, 172534, 785275, 995932, 223488, 433512
SUWANNEECOUNTY are 640802,403866,828788,751490,972562,367541,481360
NASSAUCOUNTY are 920232,727659, 471817, 983043, 578286
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |