Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This is my first post, so I hope I don't mess anything up.
I am creating a module that deals with a specific kind of xml called ettx. The object it creates is supposed to hold two hashes for comparison later. This is the code so far:
#!/usr/bin/perl -l package ETTX; use strict; use warnings; use XML::Simple; use Data::Dumper; sub load(;$){#file name my $class = shift; my $self; if(@_ == 1){ my $xml = XML::Simple->new(); $self = { ettx => $xml->XMLin(shift), #for main file template => {}, }; } else{ $self = { ettx => {}, template => {}, } } bless $self, $class; return $self; }; sub loadEttx($){ my $self = shift; my $xml = XML::Simple->new(); $self=>{ettx} = $xml->XMLin(shift); } sub loadTemplate($){ my $self = shift; my $xml = XML::Simple->new(); $self=>{template} = $xml->XMLin(shift); } 1;
However, I'm getting a compile time error which says:
Can't modify anonymous hash ({}) in scalar assignment at C:\Texts\Programs\ETTX.pm line 31, near "};"
Line 31 being the one that says "$self=>{ettx} = {};"
I can't find my error anywhere. Can anyone spot it?
Thanks! ---Nathan
|
|---|