#!/usr/bin/perl -w use strict; use Data::Dumper; use XML::Twig; my $twig= new XML::Twig; my $xml=qq~ USD 298.95 298.95 348.95 1106.62 1106.62 159.77 USD 298.95 298.95 348.95 1106.62 B ~; $twig->parse($xml); # build the twig my $struct = $twig->simplify( forcearray => 1 ); print Dumper $struct; #### $VAR1 = { 'nativeCurrencyCode' => [ 'USD' ], 'displayCurrencyCode' => [ 'USD' ], 'chargeableRoomRateTaxesAndFees' => [ '159.77' ], 'rateFrequency' => [ 'B' ], 'chargeableRoomRateTotal' => [ '1106.62' ], 'NativeNightlyRates' => [ { 'nativeNightlyRate' => [ '298.95', '298.95', '348.95' ], 'size' => '3' } ], 'DisplayNightlyRates' => [ { 'size' => '3', 'displayNightlyRate' => [ '298.95', '298.95', '348.95' ] } ], 'displayRoomRate' => [ '1106.62' ], 'nativeRoomRate' => [ '1106.62' ] };