in reply to Substitution on string held in a variable

If you want to find where the file your script was read from is, and thus find other files which might be in the same directory (or directories close), you need cpan::FindBin.
  • 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 14:37 UTC
    Hi,

    Here's the alternative using FindBin
    #!/usr/bin/perl @filelist =("includes.cgi","connect.cgi","commit.cgi"); @file =(); use FindBin qw($Bin); print "Content-type:text/html\n\n"; foreach $filelist(@filelist){ $path = "$Bin\/$filelist"; push (@file,$path); } $changed = chmod 0777,@file; foreach $file(@file){ print "$file<br />"; } print "<br />$changed files changed";


    Sid
Re: Re: Substitution on string held in a variable
by Hissingsid (Sexton) on Apr 01, 2004 at 14:04 UTC
    Hi matija,

    Thanks for the tip I'll take a look at the module.

    Meanwhile this is what I'm playing with at the moment:

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


    It seems to work just fine.

    Best wishes

    Sid