perl code doubt

S

siva rajesh

what is the meaning of

my $DIRDEPTH = "..\\..\\..";

what is the meaning of \\ and .. in perl?

thank you
Rajesh
 
P

Paul Lalli

siva said:
Subject: perl code doubt

Please put the subject of your post in the Subject of your post. Your
post is not about doubting perl code. Your post is about '\\' and '..'
what is the meaning of

my $DIRDEPTH = "..\\..\\..";

what is the meaning of \\ and .. in perl?

In a normal string, .. has no special meaning of any kind. Those are
simply two periods.

The \ is a special character. It starts an escape sequence. It makes
non-special characters special (for example, a \n means "newline"). It
also makes special characters non-special. In this case, the first \
is used to make the second \ non-special. Therefore, "\\" simply means
a single backslash.

The above string looks to be a directory location, going three levels
up from the current directory.

If you post some more context, we can probably help you figure out what
the specific chunk of code is actually doing.

Paul Lalli
 
J

John W. Krahn

siva said:
what is the meaning of

my $DIRDEPTH = "..\\..\\..";

what is the meaning of \\ and .. in perl?

Everything between quotes (") are string characters. The \ character is
special in a double quoted string in that it and the character following
it represent either a meta-character ( \n, \t, \b, etc. ) or the
character itself.

perldoc perlop


John
 
T

Tintin

siva rajesh said:
what is the meaning of

my $DIRDEPTH = "..\\..\\..";

what is the meaning of \\ and .. in perl?

same as writing

my $DIRDEPTH = '..\..\..';
 
B

Big and Blue

Paul said:
The above string looks to be a directory location, going three levels
up from the current directory.

Only on MS Windows.

On Unix it would refer to an entry called '..\..\..', which is a valid,
albeit unusual, filename.

It might be better written as:

my $DIRDEPTH = "../../..";

which would refer to 3-levels up on Windows, Unix (and MacOSX), and avoid
the reader having to work out that "\\" is actually '\'.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top