Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:
Finest monkish minds of the tubes
Getting to grips with Perl 5.10 I am trying to use a state variable in a little SAX fun I am having. To cut to the chase this bit of code
package XML::SAX::jmeter; use strict; use warnings; use 5.010; use Data::Dumper; use base qw(XML::SAX::Base); sub empty_record { return { getting => 'url', url => 'http://', match => '', getting => '', alarm => 'no', }; } state %record = %{empty_record}; #Initialization of state variables in list #context currently forbidden at ...
I also tried giving the compiler a clue ...
state %record = %{empty_record()}; state %record = %{&empty_record}; state %record = %{&empty_record()};
all the same problem.
now I am using $record holding the array ref and my code works but I would like to know why I could not get the other option to work.
Cheers,
R.
Pereant, qui ante nos nostra dixerunt!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: initialise state variable from list context, NOT!
by JavaFan (Canon) on Sep 08, 2009 at 12:40 UTC | |
by Random_Walk (Prior) on Sep 08, 2009 at 14:17 UTC | |
by JavaFan (Canon) on Sep 08, 2009 at 16:21 UTC |
Back to
Seekers of Perl Wisdom