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


In reply to Substitution query by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.