Hi, I'm going to take this from here, rather than go on to the full code, because I think I see the core of the problem here. The foreach just isn't going to do it for what you want, although you maight call it on one of the hashes. You don't really indicate whether there is supposed to be any meaningful parallelism across columns, and on that factor rests the distinction in strategy.
If the columns do have some one-to-one relationship between lines, you would want to foreach one of the hashes, then reference the corresponding element of the other. If there is no relationship across columns, then you have three jobs to do: 1) Get %TARGET into an array of preformatted strings, keeping count of the number of strings produced. 1) Get %PROD into an array of preformatted strings, keeping count of the number of strings produced. 2) For the legth of the shorter array, output an element from one array then the other on each line. 3) For the remaining length of the longer array format your output to compensate for the missing column. You note that I specified three jobs, but you see four items above. The first two should work very well with a properly parameterized sub. Jensen Kenneth B SrA AFPC/DPDMPQ wrote: > Accidentally sent before I was done writing. > > I am trying to iterate through two hashes and print each key/value. In one > column the key/value from one hash and another column the key/values of the > other hash. So the output would look something like this > > Some header | header for column 2 > Key value key value > Key value key value > Key value key value > Key value key value > Key value key value > Key value key value > Key value > Key value > > Etc... > > Here's what I am doing right now > > ($a, $b, $c) = 0; > foreach (sort keys (%TARGET)){ > @TEMP[$a] = "$_ $TARGET{$_}"; > $a++; > } > foreach (sort keys (%PROD)){ > @TEMP2[$b] = "$_ $PROD{$_}"; > $b++; > } > print OUT "\@ prod not present. | Present not at prod.\n"; > if ($a > $b){ > for ($n=0 , $n = $a, $n++){ > printf OUT "%15s %15s\n", (@TEMP[$n], @TEMP2[$n]); > } > } else { > for ($n=0 , $n = $b, $n++){ > printf OUT "%15s %15s\n", (@TEMP[$n], @TEMP2[$n]); > } > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]