It looks to me like any mention of 'now' in the parent (maybe excluding children of the parent) would make the entry not rare. So I would check just that: whether you can match 'now' in the parent's text.
You can test your code by building a quick test environment like the one below, that will let you add headers and check that your sub behaves properly:
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
use Test::More;
XML::Twig->new( twig_handlers => { header => \&test_header })
->parse( \*DATA);
done_testing();
sub test_header
{ my( $t, $header)= @_;
is( $header->att( 'expected'), is_la_rare( $header), $header->spri
+nt);
}
sub is_la_rare {
my $elt = shift;
foreach my $label ($elt->children('la') ) {
next unless $label->text eq "rare";
my $isNowRare = 0;
if ( $label->parent->text_only =~ m/[nN]ow / ) { $isNowRare =
+1; }
if ( !$isNowRare ) { return 1; }
}
return 0;
}
__DATA__
<tests>
<header expected="1"><la>rare</la></header>
<header expected="0">Now <la>rare</la></header>
<header expected="0">Now <la>hist.</la> and <la>rare</la></header>
</tests>
And it looks like xmltwig.org was down, it's back to life now, !@#$%^&* networks! Sorry for the inconvenience