Re: help with file test

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 12/23/03


Date: Tue, 23 Dec 2003 01:26:23 +0100

S.R.Sriram wrote:
> $BASEDIR is the name of the directory.

Okay. Odd, but possible.

> For the directory i gave in my example:
>
> /var/newbinary/$BASEDIR/bin/foo
>
> when i have to cd into this directory, i need to escape the "$".
>
> cd /var/newbinary/\$BASEDIR/bin/

To my knowledge, cd is not a Perl command. Are referring to a shell
command from the command prompt?? You should not assume that you can
make any conclusions out from that as regards the need to escape
things in Perl.

> My issue is that in my above code snippet, when i
>
> if (-e /var/newbinary/\$BASEDIR/bin/foo) {

Do you always write strings in Perl code without quotes? Suppose not.
Please show us what you actually wrote, or else it's hard to help you.

Btw, have you studied the posting guidelines for this group?
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

In your previous message you said that you did:

     $fileName =~ s/\$/\\\$/g;

         if (-e $fileName) {

etc., but if $fileName had been assigned the string
'/var/newbinary/$BASEDIR/bin/foo', you should _not_ add that
backslash.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl