in reply to Re^3: A short whishlist of Perl5 improvements leaping to Perl7
in thread A short whishlist of Perl5 improvements leaping to Perl7
short version:*
1. Any assignment to an undeclared new variable implies a "implicit" my when in
$x = 1 ==> my $x =1
sub foo { $x = 1; ... } ==> sub foo { my $x =1; ... }
for $x (@a) {...} ==> for my $x (@a) {...}
open $fh, ... ==> open my $fh, ...
3. No hoisting, a variable accessed before an implicit my still belongs to the upper scope and needs to be declared there
4. loop-bodies and naked blocks (technically the same) follow the old rules
{ $x=42 }; print $x; => 42
5. ( ??? ) nested/anonymous subs are tricky, when it comes to closed over vars
8. special global vars are exempt from implicit my.
9. Last but not least automine activates strict
So ...
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) actually not in the case of map and grep but for all of List::Util , try return to see the difference
*) updated
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: A short whishlist of Perl5 improvements leaping to Perl7 (Thought Experiment No.2)
by LanX (Saint) on Nov 28, 2020 at 12:48 UTC |