in reply to 'use strict' Rejecting Local Hash
At least, that's what perlsub says.
Here's what I tried:
local and my are completely different. What local does is, within its scope, save the previous value of a defined variable, restoring it when you leave the enclosing scope. Dominus has a nice article on the uses of local, and I'll see if I can find it before someone else posts a pointer.#!/usr/bin/perl -w use strict; # local %hash; # gives error my %hash; # no error { local %hash; # no error, if %hash previously declared with my # local %hash; # error if %hash previously undeclared }
Update: chipmunk and tilly are both right. I should have put use vars ( %hash ); instead of my. But the main point still stands.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: 'use strict' Rejecting Local Hash
by chipmunk (Parson) on Dec 28, 2000 at 08:35 UTC | |
by tilly (Archbishop) on Dec 28, 2000 at 09:08 UTC |