QM has asked for the wisdom of the Perl Monks concerning the following question:
I have a closure with 3 subs in it, something like this:
The script compiles and runs with no warnings or errors, and appears to "do the right thing".use strict; use warnings; { # closure my %foo; sub collect_it { my ($key, $value) = @_; $foo{$key} = $value; } sub print_it { for my $key ( keys %foo ) { print "\$foo{$key} = $foo{$key}\n"; } clear_it(); } sub clear_it { %foo = (); } } # end closure
However, some of my users want a PAR executable. When making the PAR executable (pp -z 9 -c script.pl), I get errors for all of the enclosed lexicals:
...where line "123" is a line in "script.pl" that references %foo.Variable "%foo" will not stay shared at 60oehl line 123.
From my reading I see that this error comes up in Perl when using nested named subs, which isn't the case here.
The only thing I can think of is that PAR is somehow wrapping my whole script, which then triggers the sharing warning message under "-c".
I've tried to reproduce this with a smaller script, but had no luck yet. (The original script is 1000+ lines.) I'm also wondering if the "\$foo{$key}" confuses the compiler into thinking that's a reference?
Any hints?
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PAR: Variable %x will not stay shared
by Joost (Canon) on May 25, 2006 at 12:00 UTC | |
by QM (Parson) on May 25, 2006 at 21:00 UTC | |
|
Re: PAR: Variable %x will not stay shared
by sgifford (Prior) on May 25, 2006 at 05:24 UTC | |
by QM (Parson) on May 25, 2006 at 20:47 UTC | |
|
Re: PAR: Variable %x will not stay shared
by PodMaster (Abbot) on May 25, 2006 at 03:50 UTC |