Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Trim Two Characters On Line

by johngg (Canon)
on Oct 22, 2020 at 23:14 UTC ( #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? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2023-01-29 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?