Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks I'm having some issues with trying to get a substitution working or to think of another method to do what I need done. I have the following code
find(\&all, @allpaths); open (LIST, ">$filepath/Paths.bak") or die "$! error trying to ove +rwrite"; foreach my $p (@allpathlisting) { print LIST "$p\n"; } close LIST; copy $allpatholdfile, $allpathnewfile or die "$! error trying to c +opyfile"; sub all { return unless -d; $File::Find::prune = 1 if /[IPDLMY]\d{8}$/; (my $fn = $File::Find::name) =~ tr#/#\\#; push @allpathlisting, $fn if /[IPDLMY]\d{8}$/; print "$fn\n" if /[IPDLMY]\d{8}$/; foreach (@allpathlisting) { s/gpfs_data/nas\/rdds/; } }
I want to replace /gpfs_data/ with /nas/rdds/ I'm wondering if the code below
foreach (@allpathlisting) { s/gpfs_data/nas\/rdds/; }
Could be added somehow to
(my $fn = $File::Find::name) =~ tr#/#\\#;
Because my script is taking a bit longer to run now and I can't get Perl to replace the / with \ in this bit /nas\/rdds/
Sorry for the formatting, I had comments at the ends of lines but pasting it here made the code all weird
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Substitution query
by Loops (Curate) on Nov 20, 2014 at 05:11 UTC | |
by Anonymous Monk on Nov 20, 2014 at 05:58 UTC | |
by Loops (Curate) on Nov 20, 2014 at 06:04 UTC |