in reply to Legitimate use for combined 'local' and 'our'
#!/usr/bin/perl our $V = 'non-local'; sub print_v { print "$V\n"; } { local our $V = 'local'; print_v; } print_v __END__ # output: local non-local
Since local affects variables in code you call, you have to call the sub from the scope in which you used <c>local our<c>.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Legitimate use for combined 'local' and 'our'
by JavaFan (Canon) on Nov 15, 2010 at 11:02 UTC |