From: William Martell <mailto:[EMAIL PROTECTED]> wrote:
: Hello All, : : I was wondering if someone could tell me how to manipulate : this data structure. I have attached the datafile. My code : and code results are printed below. : : If you take a look at the results, you will see that there is : a hash created for each interaction in the loop and the : results are printed using data::dumper. The problem, is that : some hash values are blank, because they are printed during : the following interaction of the loop. : : In other words. I am getting this... [snip] : and I want to get this... : : $VAR1 = { : 'waste' => '0.00', : 'promo' => '0.00', : 'count' => '5.00', : 'plu' => '00000000002800', : 'total' => '10.00', : 'description' => '6 NUGGET', : 'line' => 'PLU' : }; : : Could anyone help explain why this is occuring and how to : resolve it. Thank you all very much for reading my message. It occurs because you are resetting the %record on each pass instead of only as you see a new record begin. Try: my %record; # skip first 3 lines <FILE>; <FILE>; <FILE>; while ( <FILE> ) { if ( /^PLU/ ) { #reset record %record = (); @record{ qw| line plu description | } = get_plu_and_description($_); } elsif (/^\t/) { @record{ qw| count total promo waste | } = get_count_total_promo_waste($_); print Dumper(\%record); } } HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>