Name "main::a" used only once: possible typo at ... line ...

Posted by knorv on Stack Overflow See other posts from Stack Overflow or by knorv
Published on 2010-03-23T11:47:32Z Indexed on 2010/03/23 11:53 UTC
Read the original article Hit count: 596

Filed under:

When running the following Perl code ...

use Data::Traverse qw(traverse);
use warnings;
my $struct = [ 1, 2, { foo => 42 }, [ 3, 4, [ 5, 6, { bar => 43 } ] ], 7, 8 ];
traverse {
  print "$a => $b\n" if /HASH/
} $struct;

... the warning Name "main::[ab]" used only once: possible typo is given.

Since the use of $a and $b is clearly not a typo in this case I want to get rid of the warning. How do I do that while still using warnings?

© Stack Overflow or respective owner

Related posts about perl