#!/usr/bin/perl -- use strict; use warnings; use HTML::TreeBuilder; use Test::More qw' no_plan '; Main(@ARGV); exit(0); sub Main { is( OneT(''), undef, 'no tag means undef not empty string' ); is( OneT(''), '', 'no content' ); is( OneT(' '), ' ', 'space' ); is( OneT(qq'a\nb'), "a\nb", 'a newline b' ); } ## end sub Main sub OneT { my ( $html, $expect, $name ) = @_; my $tree = HTML::TreeBuilder->new(); $tree ->no_space_compacting(1); $tree->parse($html); return eval { $tree->look_down(qw' _tag title')->as_text }; } ## end sub OneT __END__