in reply to Re^3: my $scope as the default for variables
in thread Please help me print this hash.

Yes, but turning a single use of a lexical variable into a warning will raise warnings for code like:

use Guard; sub foo { $guard = scope_guard { print "done\n" }; ... do stuff, without ever mentioning $guard again ... };

This could maybe circumvented by only raising the warning when my is missing:

use Guard; sub foo { # This will warn $guard = scope_guard { print "done\n" }; ... do stuff, without ever mentioning $guard again ... };

Detecting this will be tricky, but it should catch most of the typos that would get a warning.

Replies are listed 'Best First'.
Re^5: my $scope as the default for variables
by Anonymous Monk on Jun 19, 2012 at 09:12 UTC

    Yes, but turning a single use of a lexical variable into a warning will raise warnings for code like: ... This could maybe circumvented by only raising the warning when my is missing

    Or it isn't a blessed Guard :) Yes, but this new scope pragma could also notice its a Guard singleton and not issue a warning -- sure it won't work for all singletons, but the popular ones could be listed, and the new ones could register themselves like you register warnings or even autodie::hints