On Thursday 11 July 2002 11:47 am, Chip Salzenberg wrote:
> According to Dan Sugalski:
> > At 9:50 PM -0400 7/9/02, Chip Salzenberg wrote:
> > >    3a. If so, how can one distinguish among the e.g. many C<my $foo>
> > >        variables declared within the current function?
> >
> > One pad per block, rather than per sub.
>
> I just remembered why I thought that woundn't work:  BEGIN is a block.
>
>    my $x = 1;
>    BEGIN { %MY::{'$y'} = \$x }
>    print $y;

Even worse, you should be able to modify lexicals even outside your scope.

sub violate_me {
    caller(1).MY{'$y'} := caller(1).MY{'$x'};    # hypothetical syntax
}

{
    my $x = 1;
    my $y;     # Might be able to BEGIN { violate_me() } instead
    violate_me();
    print $y;
}

Ashley Winters

--
When you do the community's rewrite, try to remember most of us are idiots.

Reply via email to