J
jim.goodman
please no flames... i am trying to post a thoughtful question with all
the right info so that we don't have to do this twice... )!
i want to read data from a file.... here is a sample of the data.....
1 St. Helena Napa Valley
2 Santa Lucia Highlands Monterey Bay Area
3 Oakville Napa Valley
4 Howell Mountain Napa Valley
7 Russian River Valley Sonoma
8 Santa Barbara County South Central Coast
11 Oakville Napa Valley
13 Russian River Valley Sonoma
15 Alexander Valley Sonoma
16 Ojai Valley South Central Coast
20 Valpolicella Veneto
22 Chianti Tuscany
28 Asti Piedmont
33 Chianti Tuscany
34 Shenandoah Valley of California Sierra Foothills
36 Oakville Napa Valley
37 Green Valley Central Valley
38 Yamhill Valley Willamette Valley
42 Santa Barbara County South Central Coast
45 Rutherford Napa Valley
49 St. Emilion Bordeaux
50 St. Emilion Bordeaux
51 Haut-Medoc Bordeaux
52 St. Emilion Bordeaux
53 St. Emilion Bordeaux
54 St. Emilion Bordeaux
55 Haut-Medoc Bordeaux
56 Carneros Sonoma
57 Medoc Bordeaux
each column is serated by a tab with the \n at teh end of the line....
what i want is for column tow (subregion) to be teh key and colunm 3
(region) to be the data for the key.... i have to update which
subregions are in which regions so i only want each subregion once
(using hash's and keys to keep it unique, see guys, i learned from my
last question.... <again a smile>). so later i have another script that
will update "st. emilion" in the Db as being in "Bordeaux", relating
them....
here is the code i have been working with... please understand that it
isn't complete/doesn't work. the closest i got to it working was so
many "tiral and errors" ago (mostly errors) that i don't remeber what i
did to get it to its closest point.... and therefore giving me
output.... but i think you can understand exactly what i am looking
for.....
thanks a million for any help.
-jim
#!/usr/bin/perl
use strict;
use warnings;
my $org_stuff = '/Users/goodman/Desktop/wine/test.txt'; #data file
open ORG_STUFF, $org_stuff or die "Can't open $org_stuff : $!"; # open
data or error
my %org; # declare hash
while( <ORG_STUFF> ) {
chomp;
my $org_data = ( split /\t/ )[ -2 ];
$org{ $org_data } = (); # don't care about values
}
close ORG_STUFF;
for my $org_data ( sort keys %org ) {
print "$org_data\n";
}
__END__
the right info so that we don't have to do this twice... )!
i want to read data from a file.... here is a sample of the data.....
1 St. Helena Napa Valley
2 Santa Lucia Highlands Monterey Bay Area
3 Oakville Napa Valley
4 Howell Mountain Napa Valley
7 Russian River Valley Sonoma
8 Santa Barbara County South Central Coast
11 Oakville Napa Valley
13 Russian River Valley Sonoma
15 Alexander Valley Sonoma
16 Ojai Valley South Central Coast
20 Valpolicella Veneto
22 Chianti Tuscany
28 Asti Piedmont
33 Chianti Tuscany
34 Shenandoah Valley of California Sierra Foothills
36 Oakville Napa Valley
37 Green Valley Central Valley
38 Yamhill Valley Willamette Valley
42 Santa Barbara County South Central Coast
45 Rutherford Napa Valley
49 St. Emilion Bordeaux
50 St. Emilion Bordeaux
51 Haut-Medoc Bordeaux
52 St. Emilion Bordeaux
53 St. Emilion Bordeaux
54 St. Emilion Bordeaux
55 Haut-Medoc Bordeaux
56 Carneros Sonoma
57 Medoc Bordeaux
each column is serated by a tab with the \n at teh end of the line....
what i want is for column tow (subregion) to be teh key and colunm 3
(region) to be the data for the key.... i have to update which
subregions are in which regions so i only want each subregion once
(using hash's and keys to keep it unique, see guys, i learned from my
last question.... <again a smile>). so later i have another script that
will update "st. emilion" in the Db as being in "Bordeaux", relating
them....
here is the code i have been working with... please understand that it
isn't complete/doesn't work. the closest i got to it working was so
many "tiral and errors" ago (mostly errors) that i don't remeber what i
did to get it to its closest point.... and therefore giving me
output.... but i think you can understand exactly what i am looking
for.....
thanks a million for any help.
-jim
#!/usr/bin/perl
use strict;
use warnings;
my $org_stuff = '/Users/goodman/Desktop/wine/test.txt'; #data file
open ORG_STUFF, $org_stuff or die "Can't open $org_stuff : $!"; # open
data or error
my %org; # declare hash
while( <ORG_STUFF> ) {
chomp;
my $org_data = ( split /\t/ )[ -2 ];
$org{ $org_data } = (); # don't care about values
}
close ORG_STUFF;
for my $org_data ( sort keys %org ) {
print "$org_data\n";
}
__END__