On Jan 27, 1:51 am, [email protected] (Raymond Wan) wrote:
> Hi all,
>
> I was wondering if there is a way for Perl to give me a warning if I
> redeclare a variable in a different scope (and thus masking the outer
> one). Just spent some time debugging this (which was obviously not my
> intention to give two variables the same name)...and I guess it is a
> silly mistake that I would do again and again. :-)
>
> i.e., This gives a warning:
>
> my $foo = 0;
> my $foo = 1;
>
> But this works:
>
> my $foo = 0;
> {
> my $foo = 1;
>
> }
Not that I'm aware of but you could use B::Xref to
generate a cross reference.
perl -MO=Xref -wle 'my $foo=0; { my $foo = 1; }'
...
$foo i1, i1 <---- 2 instances of '$foo'
--
Charles DeRykus
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/