in reply to localizing lexical without messing with tie ?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: localizing lexical without messing with tie ?
by ikegami (Patriarch) on Sep 08, 2010 at 03:18 UTC | |
by BrowserUk (Patriarch) on Sep 08, 2010 at 03:21 UTC | |
|
Re^2: localizing lexical without messing with tie ?
by LanX (Saint) on Sep 08, 2010 at 16:34 UTC |