Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: initialise state variable from list context, NOT!

by Random_Walk (Prior)
on Sep 08, 2009 at 14:17 UTC ( #794142=note: print w/replies, xml ) Need Help??

in reply to Re: initialise state variable from list context, NOT!
in thread initialise state variable from list context, NOT!

Thanks for the quick answer. The reason I thought I may get it to work with some hints for the compiler is that this is allowed

state %record; %record = ( getting => 'url', url => 'http://', match => '', getting => '', alarm => 'no', );

Is an empty hash considered as a safe case? Where is the border of what I can get away with?


Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^3: initialise state variable from list context, NOT!
by JavaFan (Canon) on Sep 08, 2009 at 16:21 UTC
    One of border cases is:
    sub foo { (my $foo, state $bar) = (f(), g()); ... } foo; foo; # Should g() be called?
    As for state %record;, that is allowed. It's state in a list assignment that is disallowed. But note that
    state %record; %record = ( ... );
    doesn't give you any benefits over
    my %record = ( ... );
    You will have to write it as
    state %record; %record = ( ... ) unless keys %record;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://794142]
[RonW]: james28909 Why not write a Perl program to do the task?
[choroba]: RonW Yes, but then, one day, they needed to switch from FTP to SFTP, and... but I can't give the whole talk away here :)
[RonW]: Tunnel FTP through stunnel?
[james28909]: i guess i should have done it in perl. i bet it woulnt have taken me 5 hours to figure out haha
[choroba]: In the end, I was able to upgrade Perl from 5.8.3 to 5.22 and install Net::SFTP::Foreign , at least for the task involved

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2017-05-22 21:45 GMT
Find Nodes?
    Voting Booth?