Results 1 to 5 of 5

Thread: " escape code in Perl

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    78

    " escape code in Perl

    A simple question:

    Whats the escape code for a " in a Perl string? I need it as HTML uses "s, and my Perl script would obviously treat it as the end of the string parameter as just a ", which would mess up the HTML.

    Thanks in advance.

  2. #2
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    its a \ same as in javascript so

    print "hello\"dave\"";

    would print

    hello "dave"


  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by progressive
    its a \ same as in javascript so

    print "hello\"dave\"";

    would print

    hello "dave"

    No, it would print:

    hello"dave"
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404

    Wink

    smart arse

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    You can also used ' to delimit strings - then you only need to escape the ' and \, but you lose variable interpolation:

    Code:
    print 'Hello "Dave"' . "\n";
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

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