Hello,

I'd really like some help on this.

How can I add the server's root folder of "english" to this:

~ s/_e\.shtml/_f\.shtml/

This searches all occurences of _e.shtml and replaces them with _f.shtml (it being in the same folder).

Yet, in between that, I would like to add the server's root of "french" folder in there.

For examples; and yes I know it's not right:

~ s/_e\.shtml/(French-Folder)_f\.shtml/

I would really appreciate anyone's help on this one, as I can't seem to get it right, with what I know so far.

Thank you.

Recommended Answers

All 4 Replies

#!/usr/bin/perl
use strict;
use warnings;

while(my $rec = <DATA>){
    chomp($rec);
    #the // default delimiters for a match can be changed to arbitrary delimiters
    #The following regex is delimited by {} because pattern contains forward slashes
    $rec =~ s{/English-Folder/(.+)_e\.shtml}{/French-Folder/$1_f.shtml};
    print $rec, "\n";
}
__DATA__
/English-Folder/temp.php.u1conflict
/English-Folder/temp-post01.html
/English-Folder/temp-post.html
/English-Folder/temp.txt
/English-Folder/target01_e.shtml
/English-Folder/testcomponent.html
/English-Folder/target02_e.shtml
/English-Folder/zengarden-sample.html

Outputs:

/English-Folder/temp.php.u1conflict
/English-Folder/temp-post01.html
/English-Folder/temp-post.html
/English-Folder/temp.txt
/French-Folder/target01_f.shtml
/English-Folder/testcomponent.html
/French-Folder/target02_f.shtml
/English-Folder/zengarden-sample.html

I don't know how many times I can say "thank you" to express my gratitude! Thank you so much, it worked beautifully! Cheers :)

Great! I'm glad that's what you wanted. Please remember to mark this thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.