use strict; my $list = new List; my $file = './dd.xml'; $list->set_items($file); $list->show(); package List; use strict; use XML::Simple; use Data::Dumper; sub new { my $class = shift; my $self = {}; bless($self, $class); $self->{Items} = (); return $self; } sub set_items { my $self = shift(); my $file = shift(); # Here I load the xml file my %tmp = %{XMLin($file,noattr=>1)}; $self->{Items} = $tmp{Item}; # my $d = Dumper(\$self); # print "$d\n"; } sub show { my $self = shift(); my $q = shift(); # Here I build the array of hashes my @items = @{$self->{Items}}; # my $d = Dumper(\@items); # print "$d\n"; my $i; for $i (0..$#items) { print "-------------\n"; my %hash = %{$items[$i]}; my $d = Dumper(\%hash); print "$d\n"; # my $date = $hash{Date}; } } 1;