Quoting (was 'Bug in perl?')

Discussion in 'Perl Misc' started by David K. Wall, Aug 14, 2003.

  1. It's not a bug.


    Marshall Dudley <> wrote:

    > Perl 5.005_03 built for 386 freeBSD


    freeBSD doesn't sound very Windows-ish. :)

    There are more recent versions of Perl, too.


    > I am trying to get perl to work on a windows system for the first
    > time, thus the path delimiters are \ instead of /.


    Perl will let you use / for path separators on MS-Windows.

    > For some
    > reason the following very simple code will not compile:
    >
    > $path = 'c:\home\mysite\cgi-bin\';
    > $site = 'mysite';


    From 'perldoc perlop', quote and quote-like operators:

    q/STRING/
    'STRING'
    A single-quoted, literal string. A backslash represents a
    backslash unless followed by the delimiter or another backslash,
    in which case the delimiter or backslash is interpolated.

    The "unless followed by the delimiter" is what is biting you.

    > The problem seems to be the trailing \ on line 1, but that is
    > needed as part of the path so I can't leave it out.
    >
    > Any ideas?


    You could escape the backslash; as it is you're escaping the single-
    quote.

    $path = 'c:\home\mysite\cgi-bin\\';

    Better yet, use forward slashes:

    $path = 'c:/home/mysite/cgi-bin/';


    --
    David Wall
    David K. Wall, Aug 14, 2003
    #1
    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. xyZed
    Replies:
    8
    Views:
    373
    xyZed
    Apr 5, 2006
  2. Kelly Jones
    Replies:
    1
    Views:
    92
    Stefano Crocco
    Nov 22, 2008
  3. rduke15
    Replies:
    7
    Views:
    208
    Stephane CHAZELAS
    May 24, 2004
  4. seven.reeds

    perl / ajax / js / quoting question

    seven.reeds, Jun 20, 2006, in forum: Perl Misc
    Replies:
    3
    Views:
    119
    Hobo Salesman
    Jun 21, 2006
  5. seven.reeds
    Replies:
    2
    Views:
    121
    seven.reeds
    Jun 21, 2006
Loading...

Share This Page