You don't need local for lexicals.
Just shadow the name in the inner scope. So simple:
#! perl -slw use strict; { package NewStdScalar; require Tie::Scalar; our @ISA = qw(Tie::StdScalar); sub FETCH { return ${+shift}++ } } package main; tie my $scalar, 'NewStdScalar'; $scalar=0; print $scalar; # 0 { my $scalar = "---"; # --- print $scalar; } print $scalar; # 1 __END__ C:\test>junk34 0 --- 1
In reply to Re: localizing lexical without messing with tie ?
by BrowserUk
in thread localizing lexical without messing with tie ?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |