Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: How to remove underscore at the end of the line?

by madtoperl (Hermit)
on Mar 17, 2017 at 13:06 UTC ( [id://1185030]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to remove underscore at the end of the line?
in thread How to remove underscore at the end of the line?

Hi finddata
As suggested by davido Please check below it works,
#!/usr/local/bin/perl use strict; use warnings; my $str = 'DCMS_DEMO_new_block2_checklist_tmp_rev1_'; chop $str; print "$str\n"; my $regstr = 'DCMS_DEMO_new_block2_checklist_tmp_rev1_'; $regstr =~ s/_$//; print $regstr;

OUTPUT:
DCMS_DEMO_new_block2_checklist_tmp_rev1
DCMS_DEMO_new_block2_checklist_tmp_rev1

Also for your current input, a chop will also work (which is not recommended if your input line does not have _ always at end.It will remove the last character blindly)
As other monks suggested, please try first and post the code which is not working instead of expecting the full code by other monks here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-24 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found