http://www.perlmonks.org?node_id=1023776


in reply to Re: Localizing hash keys in an AoH
in thread Localizing hash keys in an AoH

That would probably require:
local @data = @data;
else local @data would initialize empty. (At least it does, in my tests).

Suffers from "Can't localize lexical variable @data at ..."

Update: this works:

LOCAL_BLOCK_5: { local @data[0..$#data]; $_->{unit} = 'S' for @data; print Dumper \@data; }
Update 2: Just noticed kennethks solution below, that changes @data to a package (our) variable, and allows it to be localized.

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs