Hello Friends, This is my first post and I just recently started coding in Perl.
I am trying to remove some characters from a file in a pattern described below. I have accomplished the goal, but it takes two lines of code. I am wondering, if this can be reduced to a single line.
I have a file with a single line in it as follows:
/Users/name/Desktop/Reprocess_120509_171210/Name1/Name2/RDLy_XXXX_2012_03_25_1850.ruv
I am trying to modify this line so that I have only RDLy_XXXX_2012_03_25_1850 remaining, which I am then going to use as a name for a picture file by appending .png to the above name.
Here is what I did:
open (FIDR, "< $radFile");
chomp($basename = <FIDR>);
$basename =~ s/\S*RDL/RDL/; ## this removes everything before RDL but
+has ".ruv"extension
$basename =~ s/.ruv$//; ##this removes the .ruv extension.
I am wondering, can the above substitution task(of 2 lines) be accomplished in a single line? If yes, how?
Thanks a lot in advance.