For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Help using one-liner and HTML::Entities to decode string?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help using one-liner and HTML::Entities to decode string?
Kevin Zembower

2005-06-10, 8:55 pm

Can I use a perl one-liner and the module HTML::Entities to decode a =
string like this from the command line?:

select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links

It's the beginning of a very long SQL statement.

I tried these variations, to no avail:

506 echo select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links | perl -MHTML::En=
tities -ne "decode_entities()"
507 perl -MHTML::Entities -ne "decode_entities()" "select%7Bsp%7D*%7Bsp%=
7Dfrom%7Bsp%7Dcore_links"
508 perl -MHTML::Entities -ne "decode_entities()" <select%7Bsp%7D*%7Bsp%=
7Dfrom%7Bsp%7Dcore_links
509* perl -MHTML::Entities -ne "decode_entities()" <echo select%7Bsp%7D*%=
7Bsp%7Dfrom%7Bsp%7Dcore_links
510 echo select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links | perl -MHTML::En=
tities -pe "decode_entities()"
511 echo select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links | perl -MHTML::En=
tities -pe "decode_entities($_)"
512 echo select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links | perl -MHTML::En=
tities -ne "print decode_entities($_)"
513 history


Thanks for your thoughts and suggestions on this.

-Kevin
Bob Showalter

2005-06-10, 8:55 pm

KEVIN ZEMBOWER wrote:
> Can I use a perl one-liner and the module HTML::Entities to decode a
> string like this from the command line?:
>
> select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links


Those aren't HTML entities. It looks more like URI escaping

>
> It's the beginning of a very long SQL statement.
>
> I tried these variations, to no avail:


[snip]

You can apply URI::Escape like this:

$ perl -MURI::Escape -le 'print uri_unescape(shift)'
select%7Bsp%7D*%7Bsp%7Dfrom%7Bsp%7Dcore_
links

Which prints:

select{sp}*{sp}from{sp}core_links

Don't know what you need to do from there...

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com