HTML help - how to interpret text literally

Discussion in 'Perl Misc' started by Suk, Jan 22, 2007.

  1. Suk

    Suk Guest

    Hi

    I've seen some HTML tag you can use such that it will display text you
    enclose in them litereally rather than interpret as html

    For example
    <tag>
    <b>Some Text</b>
    </tag>

    Would be displayed exactly as written rather than in bold. I've
    forgotten what this tag is!!
    Does anyone know? I want to be able to display text on a web page
    literally without it being interpreted as HTML
     
    Suk, Jan 22, 2007
    #1
    1. Advertising

  2. Suk

    Brian Wakem Guest

    Suk wrote:

    > Hi
    >
    > I've seen some HTML tag you can use such that it will display text you
    > enclose in them litereally rather than interpret as html
    >
    > For example
    > <tag>
    > <b>Some Text</b>
    > </tag>
    >
    > Would be displayed exactly as written rather than in bold. I've
    > forgotten what this tag is!!
    > Does anyone know? I want to be able to display text on a web page
    > literally without it being interpreted as HTML



    This is perl newsgroup so you'll get a perl answer.

    use HTML::Entities;

    my $string = <<HERE;
    <tag>
    <b>Some Text</b>
    </tag>
    HERE

    print encode_entities($string);



    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
     
    Brian Wakem, Jan 22, 2007
    #2
    1. Advertising

  3. Suk

    John Bokma Guest

    "Suk" <> wrote:

    > Hi
    >
    > I've seen some HTML tag you can use such that it will display text you
    > enclose in them litereally rather than interpret as html
    >
    > For example
    > <tag>
    > <b>Some Text</b>
    > </tag>
    >
    > Would be displayed exactly as written rather than in bold. I've
    > forgotten what this tag is!!
    > Does anyone know? I want to be able to display text on a web page
    > literally without it being interpreted as HTML


    Since this a group on Perl, I give you one hint the Perl way:

    s/</&lt;/g;


    --
    John Experienced Perl programmer: http://castleamber.com/

    Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    John Bokma, Jan 22, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kentor
    Replies:
    47
    Views:
    1,233
    derbz
    Feb 16, 2007
  2. Replies:
    7
    Views:
    334
    CBFalconer
    Nov 5, 2006
  3. Replies:
    5
    Views:
    604
  4. David Hutto

    Using a variable literally

    David Hutto, Dec 31, 2010, in forum: C++
    Replies:
    1
    Views:
    236
    Frederik Van Bogaert
    Dec 31, 2010
  5. Eric Smith

    function to return its argument literally

    Eric Smith, Nov 15, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    89
    Malte Ubl
    Nov 17, 2003
Loading...

Share This Page