William Martell wrote: > > I am trying to work with the code I have to extract fields from a text file > report, and write the values into excel. > > I am having trouble. > > When I get to push @order_detail, %item
Looking at your code, you mean push @order_detail, \%item > I understand that this is pushing an associative array onto a list. (array > of hashes) > > I am trying to write code that will open a new worksheet in excel and print > the values of %item onto a row. When Perl encounters a certain key > (cust_number), I would like it to start a new row. > > I have tried keys(), values(), pop() but I can't get it right. I think some > of my trouble is b/c of the reference \%item. When I remove the reference > backslash operator like this %item and type print. Perl returns with the > contents in scalar. > > So. My main question is how do I access the values and keys of %item in > @order_detail??? Hi William. You're building an array of hash references. To access a hash values from a given array element, write my $cust_number = $order_detail[0]{cust_number} To do the same for each detail record, do this foreach my $detail (@order_detail) { my $cust_number = $detail->{cust_number}; } The value returned will be 'undef' if there is no such element for a given order detail record. I hope this helps. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>