Quoting (was 'Bug in perl?')

D

David K. Wall

It's not a bug.


Marshall Dudley said:
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/';
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top