Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Trim Two Characters On Line

by johngg (Canon)
on Oct 22, 2020 at 23:14 UTC ( [id://11123062]=note: print w/replies, xml ) Need Help??


in reply to Trim Two Characters On Line

You can use chop to remove a character from the end of a string, it works on $_ by default. I assume that you don't want to get rid of the line terminator so I remove it first using chomp then it gets replaced by say when the line is printed.

johngg@abouriou:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<__EOD__ or die $!; this line does not match this SUM is wrong __EOD__ say q{}; while ( <$inFH> ) { chomp; do { say; next; } unless m{SUM}; chop; chop; say; } close $inFH or die $!;' this line does not match this SUM is wro

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2025-11-06 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.