in reply to Re: My questions: new to perl
in thread My questions: new to perl
local temporarily saves a package variable. The previous value of the variable will be restored when the current scoped is exited.That's an incomplete answer. local can localized elements of lexical arrays (and hashes) as well.
my @foo; sub hello {say "@foo";} @foo = qw[Hello, world!]; hello; { local $foo[1] = "earth!"; hello; } __END__ Hello, world! Hello, earth!
strict detects errors that aren't detected by default for backwards compatibility reasons.That's the first time I hear someone claim strict has anything to do with backwards compatibility reasons. If that were true, no code written in the past 15 years would have had the need for "no strict".
use warnings; detects lots of situations which are very likely to have resulted from errors.But on other cases, it's just plain wrong - specially in cases where a linter would have been more appropriate. For instance, the code I posted above isn't warnings free (but what is warned about should be done by a linter, not by warnings, IMO).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: My questions: new to perl
by ikegami (Patriarch) on Mar 13, 2011 at 18:27 UTC | |
by JavaFan (Canon) on Mar 13, 2011 at 20:30 UTC | |
by ikegami (Patriarch) on Mar 14, 2011 at 14:40 UTC | |
by JavaFan (Canon) on Mar 14, 2011 at 21:04 UTC | |
by ikegami (Patriarch) on Mar 14, 2011 at 22:09 UTC | |
|
In Section
Seekers of Perl Wisdom