Still a newb so bear with me: I'm trying bring in data from a flatfile db and place into a hash and then create a subset of that common data. For example, I have product groupings that have multiple multiple colors in multiple sizes. I want to be able to group all skus that are size M,L, etc. I will not, however, know the size variables as every product series has its own size designations(S,M and L, and then maybe 22, 26, 28, etc).
Below is a sampling of a tab delimited file:
123400 xyz
123411 xyz M Blue
123412 xyz M Green
123413 xyz M Red
123414 xyz L Olive
123426 xyz L Blue
123445 xyz XS Blue
123467 xyz S Red
123467 xyz S Gray
etc...
---------------------
This is what I have so far. I'm able bring the data in and print ok, but I can't figure out how to get new hashes grouped by Size:
while () {
$in = <FILE>;
if ($in) {
($SKU,$Product_Series,$Color_Finish,$Size)=split('\t',$in);
if ($Product_Series eq $crate_series) {
$subsku=substr($SKU,5,2);
if ($subsku eq "00") {
}else{
$ProductSeries{$SKU} = {'Size' => $Size,'Color_Finish' => $Color_Finish};
} else{ last; } # end of Database
}
foreach $SKU(sort keys %ProductSeries) {
print " $SKU: ";
print "Product Size: $ProductSeries{$SKU}{Size} - ";
print "Color finish: $ProductSeries{$SKU}{Color_Finish}<br>";
}
Thanks, Rich
Below is a sampling of a tab delimited file:
123400 xyz
123411 xyz M Blue
123412 xyz M Green
123413 xyz M Red
123414 xyz L Olive
123426 xyz L Blue
123445 xyz XS Blue
123467 xyz S Red
123467 xyz S Gray
etc...
---------------------
This is what I have so far. I'm able bring the data in and print ok, but I can't figure out how to get new hashes grouped by Size:
while () {
$in = <FILE>;
if ($in) {
($SKU,$Product_Series,$Color_Finish,$Size)=split('\t',$in);
if ($Product_Series eq $crate_series) {
$subsku=substr($SKU,5,2);
if ($subsku eq "00") {
}else{
$ProductSeries{$SKU} = {'Size' => $Size,'Color_Finish' => $Color_Finish};
} else{ last; } # end of Database
}
foreach $SKU(sort keys %ProductSeries) {
print " $SKU: ";
print "Product Size: $ProductSeries{$SKU}{Size} - ";
print "Color finish: $ProductSeries{$SKU}{Color_Finish}<br>";
}
Thanks, Rich