[Solved] String replacement in Perl after comparing with the original string


Now as you can see in the comment in your question that you really need to be specific about where you are actually stuck in to ask a question in SO. However, after looking at your other questions in SO it looks like you are completely new in programming world and need serious helping hand. Hence I think it would be helpful for you to get some useful reference to solve your problem.

If I breakdown your main problem statement I can see three parts

1. Need to extract the file name,
Most recommended way to do it is using File::Basename. However, its possible to use regex too. You need to learn how to write regex and how to capture a group. This link should be really helpful.

2. Compare it with variable,
Whichever method you use from above you should get the filename in a variable or in $1. Just compare that whatever you want to compare with. Make sure to use eq instead of ==. Find more details here.

3. Append the new variable to the string,
By now you should have the old filename in a variable, say $oldname, from first step and the new filename in another variable, say $newfilename. This question is already answered several times in SO, like this one. Hope that helps.

The actual solution is merely a 3 or 4 lines of code which I want you to figure out. Good luck.

0

solved String replacement in Perl after comparing with the original string