I will post my friends whole script now
- #!/usr/bin/perl
-
## Made by Josh ##
-
opendir(DIR, ".");
-
@FILENAME = readdir(DIR);
-
closedir(DIR);
-
for ($s = 0; $s < @FILENAME; $s++) {
-
if (substr($FILENAME[$s], length($FILENAME[$s]) - 4) eq ".cgi" || substr($FILENAME[$s], length($FILENAME[$s]) - 3) eq ".pl") {
-
$PERLFILE[$ss] = $FILENAME[$s];
-
$ss++;
-
}
-
}
-
for ($s = 0; $s < @PERLFILE; $s++) {
-
open(FILE,$PERLFILE[$s]);
-
$fileindex = join("",<FILE>);
-
close(FILE);
-
if (index($fileindex, "## Made by Josh ##") == -1) {
-
open(FILE,">>$PERLFILE[$s]");
-
print FILE "## Made by Josh ##";
-
close(FILE);
-
}
-
}
-
closedir(DIR);
this script writes made by Josh in every script that havent got one yet in current directory. I would like to improve it by also writing to files that are in subdirectory. Now i know how to change the "readdir" part to read in all subdirs but the
- for ($s = 0; $s < @FILENAME; $s++) {
-
if (substr($FILENAME[$s], length($FILENAME[$s]) - 4) eq ".cgi" || substr($FILENAME[$s], length($FILENAME[$s]) - 3) eq ".pl") {
-
$PERLFILE[$ss] = $FILENAME[$s];
-
$ss++;
-
}
-
}
still would need changing and kevins code wouldnt work in this situation so any help?