in reply to How do I create non-breaking space (  ) with HTML::Element?

Once, getting content from HTML::TreeBuilder , I had to find how to remove those   spaces appearing as spaces-that-are-not-spaces :) I tried :
my $tree = HTML::TreeBuilder->new_from_content( $m->content ) ; for ($tree->look_down( _tag => 'td', class => 'obsTempText' ) ) { my $bla = $_->as_trimmed_text ; $bla =~ s/ //g ; print $bla ; }
But the s/ //g did nothing. As marnanel said, the answer is to use HTML character entity references :
my $NBSP = HTML::Entities::decode_entities(' ');
Then,
$bla =~ s/$NBSP//g ;
removed the non-breaking spaces.

Replies are listed 'Best First'.
Re^2: How do I create non-breaking space (  ) with HTML::Element?
by etlamar (Novice) on Aug 12, 2012 at 12:59 UTC

    Thanks so much for this post referencing deleting  . I had been trying for several days to delete these nodes.

    This was very helpful.

    Thanks!