in reply to Re^5: Array ending up empty when processing more than a single file
in thread Array ending up empty when processing more than a single file

As I said: I'm confused...

> There's just no "warning, the variable WILL stay shared" :-P

There might be no warning, but it's still the same problem.

You proved that from the second run on $var isn't shared anymore.

Just a minor change to your code, and the warning appears:

use strict; use warnings; $\ = $/; tst() for (1..2); sub tst { my $var = 1; print \$var, " created"; sub func { print \$var; } func(); }
Variable "$var" will not stay shared at d:/pm/wont_stay_shared.pl line + 13. SCALAR(0x4c97f0) created SCALAR(0x4c97f0) SCALAR(0x4a8420) created SCALAR(0x4c97f0)

Looks like you found a case insufficiently covered by warnings!

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^7: Array ending up empty when processing more than a single file
by Eily (Monsignor) on Oct 06, 2017 at 08:10 UTC
      > I see you're definitely right.

      Repent!

      15 "Ave Larry" and kiss my bishop's ring! xD

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!