in reply to Re: Inner subroutines?
in thread Inner subroutines?

You could do just as well inside another subroutine instead of just a bare block

I'm not seeing that:

use warnings; use strict; use warnings; use strict; sub outer { my $data = 10; sub test { print $data; } } outer(); test(); --output:-- Variable "$data" will not stay shared at t.pl line 8. 10

Nor here:

use warnings; use strict; sub outer { my $data = 10; sub test { print $data; } test(); } outer(); --output:-- Variable "$data" will not stay shared at t.pl line 8. 10

Replies are listed 'Best First'.
Re^3: Inner subroutines?
by blakew (Monk) on Feb 18, 2011 at 00:27 UTC
    You're right it was a bad suggestion, I'm not sure what's going on here, it seems the variable isn't initialized until a call to outer; subsequent calls to outer() don't retain the initial reference but inner() does?