http://qs321.pair.com?node_id=780641


in reply to Re^3: Array to hash converstion
in thread Array to hash converstion

#!/usr/bin/perl -w use strict; use warnings; my @data_list = ( {key => 'correct', value => 'Article_text1'}, {key => 'correct', value => 'Article_text2'}, {key => 'date', value => '2009-01-01'}, {key => 'date', value => '2009-01-02'} ); my @correct; my @date; for my $data_pair (@data_list) { print "Value:$data_pair->{value}:Key:$data_pair->{key}\n"; if($data_pair->{key} eq 'correct'){ @correct = $data_pair->{value}; } if($data_pair->{key} eq 'date'){ @date = $data_pair->{value}; } } print "The array is @correct\n"; print "The array is @date\n";
The array stores only the last value. How to store all the values into array