http://www.perlmonks.org?node_id=909423

Trihedralguy has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I've been using encode_entities very successfully, it seemed better at the time, but I've been inserting my data into a db with encode_entities. Displaying them on a website was as simple as just select column from table. Now however, I would like to use that same data on a device that is not web, AKA doesnt render entities. I tried to do the following:
my $string = "foo   bar"; $string = decode_entities($string); print $string
But my data just comes back as my input, what I'm I doing wrong here?

Replies are listed 'Best First'.
Re: Quick decode_entities Question
by ikegami (Patriarch) on Jun 13, 2011 at 19:10 UTC

    Personally, I get

    Undefined subroutine &main::decode_entities called at -e line 2.

    Adding use HTML::Entities; provides the missing decode_entities, but you must be using something else if you're having the problem you describe.

Re: Quick decode_entities Question
by davido (Cardinal) on Jun 13, 2011 at 19:11 UTC

    What you have typed in there actually doesn't produce foo   bar? Is that the actual code that replicates the problem? Because it doesn't cause me any trouble at all, assuming I use HTML::Entities;

    Similarly, say decode_entities( encode_entities( 'this and that' ) ); produces exactly 'this and that' for me.

    Is it possible that in reducing the example to minimal code you eliminated the problem without realizing it? Because I can't duplicate it with that code.

    If the above code is giving you trouble I think we're going to need to know a little more about the rest of the neighborhood. That snippet cannot fail all by itself. What modules and pragmas are in use? Is there a character-set mismatch?


    Dave

      for me encode is working but decode is giving same error :( !!!
        the problem is on line 42, naturally