use XML::Simple; .. my $outputInfo = qx[$cmd]; $outputInfo =~ s/^.*?(?=<\?xml)//s; my $ref = XMLin($outputInfo));