G
glob
#!perl
# highly butchered version of real-world code
# just to demonstrate the issue.
use strict;
use Win32::OLE;
my $field = 'bad@id';
if ($field =~ /^([^\@]+)\@(.*)/) {
my $dom = Win32::OLE->new('Msxml.DOMDocument');
$dom->loadXml('<moo><bad id="1" /></moo>');
$dom->documentElement->SelectSingleNode($1)->getAttribute($2);
}
my $desc = 'i am:testing';
$desc =~ s/^([^:]+)/$1/;
print "$desc\n";
__END__
this prints out "bad:testing", not "i am:testing".
changing the SelectSingleNode calls to create a new string fixes the
problem:
$dom->documentElement->SelectSingleNode("$1")->getAttribute("$2");
i found it interesting that the issue continues even thou $dom is out
of scope.
that is all, just had to share / vent. took me a while to track down.
-byron
# highly butchered version of real-world code
# just to demonstrate the issue.
use strict;
use Win32::OLE;
my $field = 'bad@id';
if ($field =~ /^([^\@]+)\@(.*)/) {
my $dom = Win32::OLE->new('Msxml.DOMDocument');
$dom->loadXml('<moo><bad id="1" /></moo>');
$dom->documentElement->SelectSingleNode($1)->getAttribute($2);
}
my $desc = 'i am:testing';
$desc =~ s/^([^:]+)/$1/;
print "$desc\n";
__END__
this prints out "bad:testing", not "i am:testing".
changing the SelectSingleNode calls to create a new string fixes the
problem:
$dom->documentElement->SelectSingleNode("$1")->getAttribute("$2");
i found it interesting that the issue continues even thou $dom is out
of scope.
that is all, just had to share / vent. took me a while to track down.
-byron