Re: Paths help
- From: Josef Möllers <1700-820@xxxxxxxxxxxxx>
- Date: Sun, 12 Mar 2006 15:54:13 +0100
hope@xxxxxxxx wrote:
I trying to sort out how to put in pathes
I have apache setup like
C:\apache\Apache2\
cgi-bin
Htdocs
Now in my cgi-bin folder I have a folder called test
In this folder I have a script called test.cgi
It has in it
## GET USERS
$folder="users\\uxxx\\perdata\\users";
@userfiles=`dir $folder`;
$folder="users/uxxx/perdata/users";
Now my users are in
C:\apache\Apache2\htdocs\web1\test\users
I have put in
$folder="..\\..\\htdocs\\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="../../htdocs/web1/test/users";
That does not work
I have put in
$folder="htdocs\\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="htdocs/web1/test/users";
That does not work
I have put in
$folder="\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="/htdocs/web1/test/users";
That does not work
It appears that you have just randomly changed things in the hope that, at
one point, the script would behave as you expect it to behave.
It reminds one of the idea that, given enough monkeys with typewriters, one
day Shakespear's Hamlet will be typed by one of them.
The drawbacks of this approach are
1. You have no idea why it suddenly works
2. You have no idea what the side effects of your action are.
You may have built in a large security hole or a bug that will bite you in
the furture.
PLEASE can some one help on this paths thing for me
1) why the two \\ in the first one
The backslash (\) is a special character in Perl's double-quoted strings: it
sometimes gives special meaning to the letter which follows it: it will
turn an n into a newline, an r into a carriage return, a closing " into a
quote within a string etc. Here it will turn the special character \ into a
simple character \.
2) Then why the/ on the second one.
The / is not a special character in Perl's strings (Note that some OSes do
not mind if you wrote a//path//to//a//file).
The difference between these two strings will become obvious, if you use
them with external programs:
The first strings will turn into 'a\path\to\a\file' (note the single quote!)
while the second ones will turn into 'a/path/to/a/file'. If you pass either
of these strings to a
@userfiles=`dir $folder`;
the "dir" command will, in one case, find a backslashed path and in the
other case a forward-slashed path. The first one is OK, the second one
isn't.
Beware that if you passed a pathname to a Perl-builtin, then perl will
automagically convert forward slashes to a backslashes.
Can you please explain in simple terms how you go from one folder up from
where you are or down from where you are.
See Brian's post.
--
josef punkt moellers bei gmx punkt de
.
- Follow-Ups:
- Re: Paths help
- From: Tad McClellan
- Re: Paths help
- References:
- Paths help
- From: hope
- Paths help
- Prev by Date: Re: how to check whether Display variable is set or not
- Next by Date: Re: Turning a list of scalars into an array?
- Previous by thread: Re: Paths help
- Next by thread: Re: Paths help
- Index(es):
Relevant Pages
|