> How usable is this ?
>
> I may be missing something, but if every variable mentioned in an anonymous
> block is assumed to be declared with my, then how do you access or modify
> the value of any variable outside the block ?
>
> Graham.
I knew someone was going to ask this; after I sent it I realized I
should have included an example.
There's two ways I see it:
1) do {} block
$val = do {
$x = 10;
# ... stuff happens ...
$y;
};
In which case $val = $y.
2) explicit our() scoping
$x = 10;
our $y = 10;
{
$x = 5; # auto-my'ed
$y += $x; # $y already our'ed above
}
print "$y"; # 15
Remember, you can still override the scopes I propose with an explicit
my or our. Admittedly, 'blocks' is not nearly as big a benefit as 'subs'
is, but has some applications, particularly if you're a "likes anonymous
blocks" kind of person (which some people are).
-Nate