Results 1 to 6 of 6

Thread: How to translate HTML symbols to normal text in Perl

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    How to translate HTML symbols to normal text in Perl

    I have a script program that I tried using the following code:

    Code:
      '
      '
      $value =~ tr/+/ /;
      $value =~ tr/%21/!/;
      $value =~ tr/%22/"/;
      $value =~ tr/%25/%/;
      $value =~ tr/%26/&/;
      $value =~ tr/%28/(/;
      $value =~ tr/%29/)/;
      $value =~ tr/%2C/,/;
      $value =~ tr/%2F/|/;
      $value =~ tr/%3C/>/;
      $value =~ tr/%3D/=/;
      $value =~ tr/%3E/</;
      '
      '
    Unfortunately it does'nt do what I though it would do.

    I want to take each HTML code like %xx and change it to the real character.

    For example %3E = "<" and %3C = ">"

    Anyone know how to do this?


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: How to translate HTML symbols to normal text in Perl

    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to translate HTML symbols to normal text in Perl

    The example from that link don't work

    my $original = "Colon : Hash # Percent %";
    my $escaped = uri_escape( $original );
    print "$escaped\n"; # 'Colon%20%3A%20Hash%20%23%20Percent%20%25'

    Once it hits the 2nd line nothing else beyond that point is executed


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: How to translate HTML symbols to normal text in Perl

    Do you have URI::Escape installed?

    Run the following from a terminal/console window:
    Code:
    perl -MURI::Escape -e ""
    If it reports URI::Escape not found, then you need to install it with:
    Code:
    cpan URI::Escape
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to translate HTML symbols to normal text in Perl

    I was wondering about that myself. I don't really have access to the Perl interpreter as it is owned by the hosting company of my web site where I keep the Perl CGI programs I write. Maybe I need to contact C.S. at the company and address this with them.

    Thanks for your help


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  6. #6
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: How to translate HTML symbols to normal text in Perl

    Yes. I would contact your hosting company to see if they have that module available. They might even install it for you, if you get lucky. I would think it must be a popular module since it's referenced from the PerlFAQ.

    Failing that, you could include the module yourself by putting the module file(s) into a separate directory (outside of the www root) and then including it with a combination of lib and FindBin.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width