Thank you for posting some code. It's not a great code example because it contains code that is not part of the problem, doesn't compile, and doesn't demonstrate how it's being used with some sample data. But it's enough to test your assertion.

The portion of what you posted that is relevant to your assertion that the code snippet provided in this thread doesn't work is the first three lines of the subroutine ir().

# First three lines of your subroutine, ir() with the prototype remove +d because it's not useful: sub ir { my $prefix = shift @_; $prefix=~ s/_$//; print $prefix,"\n"; } # A loop to test those first three lines of your code to see if they w +ork: while(<DATA>) { chomp; ir($_); } # Sample input you provided: __DATA__ DCMS_DEMO_ DCMS_DEMO_new_block2_ DCMS_DEMO_new_block2_checklist_tmp_ DCMS_DEMO_new_block2_checklist_tmp_rev1_

....output....

DCMS_DEMO DCMS_DEMO_new_block2 DCMS_DEMO_new_block2_checklist_tmp DCMS_DEMO_new_block2_checklist_tmp_rev1

It works.


Dave


In reply to Re^5: How to remove underscore at the end of the line? by davido
in thread How to remove underscore at the end of the line? by finddata

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.