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.

In reply to Substitution or removing characters from a file by hary536

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.