On Jul 10, Messervy, Joe M said:
>#!/usr/bin/perl -w
>
>use File::Copy;
>
>opendir MYDIR, "." or die "egad!: $!";
>@allfiles = grep !/^\.\.?$/, readdir MYDIR;
>closedir MYDIR;
>
>foreach $allfiles (@allfiles) {
>copy("config", "config.$allfiles");
>eval "s//mydirectorystucture/log//mydirectorystucture/log/$allfiles/g"
>}
You're never changing the contents of any of the files. And even if you
were, your eval() line is silently broken.
I wouldn't suggest using File::Copy if what you really need to do is make
a filter.
open CONFIG, "< config" or die "can't read config: $!";
for my $file (@allfiles) {
open NEW, "> config.$file" or die "can't write config.$file: $!";
while (<CONFIG>) {
s!(/mydirectorystructure/log)!$1/$file!g;
print NEW;
}
close NEW;
seek CONFIG, 0, 0; # rewind CONFIG
}
It might be better for you to just put the lines of CONFIG into an array,
but I've not done any benchmarks.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **