in reply to Substitution on string held in a variable

What I'm trying to do is use $ENV{'SCRIPT_FILENAME'} as the path to the script and then as I know the name of the script substitute that name for the names of other files in the same directory the permissions of which I will than go on and change.
it is especially that paragraph i'm simply not understanding.
please can you add some commas or other punctuation, i'm not a native english speaker.
but at least i can understand your code. your replacing the string 'permissions.cgi' (1) in $path three times. the first time it is substituted it will be gone! i hope that's clear. so what do you have in there before and what do you want in there after? that's something we can work on.

(1) besides that, please note, that you're not replacing the string permissions.cgi but the dot stands for (almost) any character. you want to put a backslash before it.
  • Comment on Re: Substitution on string held in a variable

Replies are listed 'Best First'.
Re: Re: Substitution on string held in a variable
by Hissingsid (Sexton) on Apr 01, 2004 at 11:22 UTC
    Hi,

    Sorry about my English, I have no excuse, just lazyness.

    Thanks for pointing out my two errors.

    This now works perfectly:

    #!/usr/bin/perl @filelist =("includes.cgi","connect.cgi","commit.cgi"); print "Content-type:text/html\n\n"; foreach $filelist (@filelist){ $path = $ENV{'SCRIPT_FILENAME'}; $path =~ s/filelist\.cgi/$filelist/gi; print "$filelist -- $path<br />"; }


    Thanks again

    Sid