use strict; use warnings; use XML::Simple; use Data::Dumper; use File::Slurp; ## test script to verify the way xml is parsed## ## $xmlfile is set to data of a format that would be expected to be passed to this if used in a loop ## my $xmlfile = '-1ListPerformances1433796462559TMS2015060400000157zClosing Shutdown 3D v6 - New2010010100000038zClosing Shutdown 3D v6 - New15152015-06-08T00:30:00-07:00truetrue4642015-06-08T00:30:00-07:00464falsefalsetrue696969false10false2015-06-08T00:37:44-07:00true0falsetrue2015060400000164zMorning Startup 3D v32011061100000013zMorning Startup 3D v315152015-06-08T12:10:00-07:00truetrue102015-06-08T12:10:00-07:0010falsefalsetrue696969false10false2015-06-08T12:10:10-07:00true0falsetrue2015060200000562* Movie1 3D-AV2015060800000048w23_3DP1_Sanandreas_SCCAP_0421pre_150605_02222_TMS_15152015-06-08T12:55:00-07:00truetrue81952015-06-08T12:29:18-07:009737en,en,en,en,en,en,en,en,en,enUS-G US-G US-G US-G US-G US-G US-G US-G US-G US-G falsefalsetrue696969true10false2015-06-08T15:11:35-07:00true000343929falseUS-13trueb863a576-d8a3-4f5d-92a7-b66f876f6d7cPreshow1true3D_Advertisement1a55164d0-faa7-4c7c-a688-ed36011add95Postshow12015060200000563* Movie1 3D-AV2015060600000017w23_3DP1_Sanandreas_SCCAP_0421pre_150605_02062_TMS_15152015-06-08T16:05:00-07:00truetrue81952015-06-08T15:42:13-07:009562en,en,en,en,en,en,en,en,en,enUS-G US-G US-G US-G US-G US-G US-G US-G US-G US-G falsefalsetrueFFFFFFtrue10false2015-06-08T18:21:35-07:00true000343929falseUS-13true760eb073-81f8-45cb-8553-484c5cecb740Preshow1true3D_Advertisement1a55164d0-faa7-4c7c-a688-ed36011add95Postshow1'; my $performancelist=XMLin($xmlfile, forcearray => 1, KeyAttr => {EventInfo => 'EventId'} ## #ventID is a unique value that I want to use as a key value ## ); write_file 'mydump.log', Dumper($performancelist); ## this is where nothing happens ## foreach my $performance (@{$performancelist->{MessageBody}->{ListPerformancesResponse}->{EventInfoList}->{EventInfo}->{EventId}}) { my $output=$performance->{PreshowPackList}->{PreshowPack}->{PackId}; print "Debug: $output.\n"; }