XML::Twig::XPath - strange problem



The following short test program is the kernel of a problem I'm having using xpath searches with XML::Twig::XPath elements. Can someone help me find out what I'm doing wrong? It seems that if I use my own subroutine to do the xpath search I get an error from the Twig code, but if I code the same statements inline the results are what I expect.

============ Test program ================
#!/usr/bin/perl

use strict;
use warnings;
use XML::Twig::XPath;
# ----------------- problem section of code -------------------
# This way fails
#my $da_xml = new XML::Twig::XPath;
#$da_xml = get_xml();

# This way works
my $da_doc = new XML::Twig::XPath;
$da_doc->safe_parsefile("test.xml");
my $da_xml = $da_doc->root;
# -------------------------------------------------------------

my @f = $da_xml->findnodes("//bkfile[b_filename='testfile']");
$f[0]->print;
print "\n";

sub get_xml {
        my $da_xml = new XML::Twig::XPath;
        $da_xml->safe_parsefile("test.xml");
        return $da_xml->root;
}

============= test.xml ==============
<bkdirectory>
  <bkfile>
    <dbid>445</dbid>
    <b_path>/nfb</b_path>
    <b_filename>testfile</b_filename>
  </bkfile>
</bkdirectory>
=====================================

My results, using the program as above:
[nfb@neptune lib]$ ./tryerr.pl
<bkfile><dbid>445</dbid><b_path>/nfb</b_path><b_filename>testfile</b_filename></bkfile>

Switching the comments so the "failing" section is active I get:
[nfb@neptune lib]$ ./tryerr.pl
Can't use an undefined value as a HASH reference at /usr/lib/perl5/site_perl/5.8.6/XML/Twig/XPath.pm line 114.


Environment is Fedora Core 4, Perl 5.8.6; XML::Twig::XPath is "v 1.15 2005/07/05 10:47:19"

--

Henry Law       <><     Manchester, England
.