Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Quick decode_entities Question

by Trihedralguy (Pilgrim)
on Jun 13, 2011 at 18:48 UTC ( #909423=perlquestion: print w/replies, xml ) Need Help??
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 (Pope) 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 (Archbishop) 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?


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://909423]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2018-06-23 18:49 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.