#!/usr/bin/perl -l package SIFX; use strict; use XML::Simple; use Data::Dumper; sub new(){#scalar file name optional my $class = shift; my $self = { etaxFile => '', SIFX => {}, }; bless $self, $class; load($self,shift) if @_ ==1; return $self; } sub load(){ return -1 if(@_ == 0); my ($self, $input) = @_; my $sifx; if((substr $input, -4, 4) eq '.txt'){#if input was a file name $self->{etaxFile} = $input; open my $etax, ''){#until beginning of SIFX chomp($text = <$etax>); } $sifx= ''; do{#until end of SIFX chomp($text = <$etax>); $sifx .= $text; }while($text !~ m##); close $etax; } else{ $sifx = $input; } my $xml = XML::Simple->new(); $self->{SIFX} = $xml->XMLin($sifx); print "SIFX hash is : "; print Dumper($self->{SIFX}); } 1;