in reply to Re: Need an $a and $b as in perl's sort routine
in thread Need an $a and $b as in perl's sort routine

Wouldn't doing a local $::row={} leave '$row' defined in main even outside the code block, however? I'd like $row to disappear once the instruction is complete.
  • Comment on Re^2: Need an $a and $b as in perl's sort routine

Replies are listed 'Best First'.
Re^3: Need an $a and $b as in perl's sort routine
by demerphq (Chancellor) on Jan 11, 2006 at 00:53 UTC

    No it wouldn't. Or rather $::row would revert to whatever it was before you localized it once you exited the sub that contains the localization. In the example below i use a bare block instead of sub to demonstrate but the same thing applies.

    D:\dev\PM>perl -le"$::x='outer'; $c=sub{print $::x}; { local $::x='inn +er'; $c->() } $c->()" inner outer

    Thats the whole point of dynamic scoping...

    ---
    $world=~s/war/peace/g