use XML::Simple; local $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; $xml->XMLin($file,ForceArray => ['map'], KeyAttr =>{},); #### package ETTX; use strict; use XML::Simple; local $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; use XML::SemanticDiff; sub new(){#scalar file name my $class = shift; my $self = { ettxFile => '', ettx => {}, }; bless $self, $class; load($self,shift) if @_ ==1; return $self; }; sub load(){#scalar file name my ($self, $ettxFile) = @_; print "loading $ettxFile"; open(my $fh, '<', $ettxFile); binmode($fh); my $xml = XML::Simple->new(); $self->{ettx} = $xml->XMLin($fh, ForceArray => ['map'], KeyAttr => {}, ) ->{table}; $self->{ettxFile} = $ettxFile; # print Dumper($self); 1; } #### use lib 'C:\Texts\Programs'; #wherever ETTX.pm is use ETTX; my $ettxFile = 'someXMLfile.ettx'; my $ettx->load($ettxFile); ####