On Jan 27, 1:51 am, r....@aist.go.jp (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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to