Guy P wrote:
> Look at the small program below.
> The result is this: DirectionsNitprogrsourcsql
> DirectionsNitprogrsourcsql
>
> And I would like it to be this: \Directions\unit\progr\sourcsql
...
>
> $reprt= "\Directions\unit\progr\sourcsql";
...Hi Guy,
You are comparing apples and oranges here. The string in $reprt above is not
equivalent to what the variable would hold if you got it from the database.
> > My Perl program execute a query that bring back into a
> > variable a Windows paths initially stored in a database. I
> > have got problems to manage the backslash.
To express what the variable would hold if read from the database, you would have to
escape each backslash with another backslash.
All control characters within interpolated strings require backslashes to escape them.
This makes the packslash itself a control character.
Each backslash must then be escaped.
Solutions:
Escape each backslash:
$reprt = "Directions\\unit\\progr\\sourcsql";
OR use a non-interpolated [single-quoted] string:
$reprt = 'Directions\unit\progr\sourcsql';
OR skip trying to hard-code the string in a variable, and instead test by reading the
string from the command line. If you do this, there will be no need to escape control
characters, as that will already be done under the surface.
Joseph
OT:
You might note that I also removed the initial backslashes. If you are working in
Windows, there is no context in which they will be needed. If you have a tree
structure:
C:\
biology\
botany\
zoology\
protozoan.txt
echinoderm.txt
Your current directory is biology. to access echinoderm.txt in the zoology folder you
would address it as zoology\echinoderm.txt, with no initial control characters of any
kind.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]