When I run this Perl script:
#!/bin/perl
use XML::Bare;
$ob = new XML::Bare(text=>'<xml><name>Bob</name></xml>');
for $i (keys %{$ob->{xml}}) {print "KEY: $i\n";}
I get no output. However, if I put $ob
inside a my()
:
#!/bin/perl
use XML::Bare;
my($ob) = new XML::Bare(text=>'<xml><name>Bob</name></xml>');
for $i (keys %{$ob->{xml}}) {print "KEY: $i\n";}
I get this output:
KEY: _z
KEY: _i
KEY: xml
KEY: _pos
Why does my()
change this behavior so drastically, especially given
that I'm at the top level where my()
should have no effect at all?