#!/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>.
In reply to Re: Legitimate use for combined 'local' and 'our'
by moritz
in thread Legitimate use for combined 'local' and 'our'
by jeteve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |