#! /usr/bin/env perl use XML::Simple; use Data::Dumper; use strict; use warnings; use 5.012; ######## ########### Variables ######## # List of info we want for each message entry my @keysToKeep = ('date', 'body', 'address', 'type'); # XML Parser my $xml = new XML::Simple; ######## ########### Subroutines ######## # Filepath is passed to load a hashref # a CLEANED Hashref is returned of the xml we've loaded sub loadFileToHashRef { my $xmlRef = $xml->XMLin($_[0]); while (($key, $value) = each %{$xmlRef}) { print "Key: $key, Value: $value \n"; } # Return our hash ref return $xmlRef; } my $hashRef = loadFileToHashRef("xml/sms-20110704030000.xml"); print Dumper $hashRef;