The code is #!/usr/bin/perl use strict; use warnings; use File::Slurp; use Data::Dumper; my %graph_point_hash; my @report_graph_point = `sed -e 's/data//g' -e 's/[\<\/\>]//g' -e 's/^ *//' -e 's/* \$//' -e '/^\$/d' -e '1d;\$d' $ARGV[0]`; my @split_graph_points; foreach (@report_graph_point) { @split_graph_points = split (' ', $_); foreach my $graph_point (@split_graph_points) { $graph_point =~ s/"//g; my ($key, $val) = split ("=", $graph_point); push (@{$graph_point_hash{$key}}, "$val"); } #foreach loop ends here } #foreach loop ends here print Dumper \%graph_point_hash; XML file is THE OUTPUT IS $VAR1 = { 'w' => [ '0', '0', '0.00', '5.50', '0.00', '2.50', '0.00', '489.50', '0.00', '0.00', '0.00', '0.00', '0.00', '242.00', '0.00', '0.00', '0.00', '5.50', '0.00', '4.00',