|Do you know where your variables are?|
Re: help pleaseby Revelation (Deacon)
|on Mar 26, 2002 at 01:58 UTC||Need Help??|
The readdir() function will return ., and .. as directories, in addition to the other directories on under that directory.. I'm not sure you want to use that, as you may end up coding a reverse recursive function, until you have done this to every directory you have access to. To fix this you may wish to do something as simple as greping to check if your result is actually there.
Also: Instead of -d $dirname, it may be simpler to just die, if the directory can't be opened?
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
Or you can write a function to nicely die, and output the reason for it to the user. Just remember to exit;, with that function.
so: instead of
You Could Use:
And you'd have a list of everything in the directory, without . and .., and with diff arrays for directories and files. In fact, since you're only editing certain types of files, you could change the first grep to suit your needs, with a regex, or you could add a few greps for the differant types of files, which would let you change shtml files to html files rather easily. If you want to have only two greps, then use && regex.
It's also my opinion that your teacher will not be very happy if you use a ton of perl modules, as the point of this excersize seems to be to test your knowledge of perl, not the writer of a perl modules' knowledge. Using a perl module is like using somebody else code, which is alright in the GNU/perl world, but is not alright in school. I would advise hard coding much of it, and adding comments to show your teacher that you know perl modules.