Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How to remove last character of a line

by GrandFather (Saint)
on Mar 23, 2021 at 03:10 UTC ( [id://11130170]=note: print w/replies, xml ) Need Help??


in reply to How to remove last character of a line

Can you really be this thick and unproductively lazy? Surely it takes more time to get an answer here by the time you have written your question and waited, even if just a few minutes, for an answer?

Get used to trying things out for yourself. Write some trivial code and play with it to see what makes a difference. It will take less time and you will learn more and become more productive than this constant spamming us with badly presented trivia questions.

Here's something to play with to get you started:

use strict; use warnings; my $inLine = ".abc(abc), \n"; print "'$inLine'\n"; chomp $inLine; print "'$inLine'\n"; chomp $inLine; print "'$inLine'\n"; chop $inLine; print "'$inLine'\n";

Run that code for yourself and work out why it prints whatever it prints, then play with it to see what happens. Ask yourself "Why did he put $inLine in single quotes?". Ask yourself "Why did he put a new line at the end of each print?". Ask yourself "Why did he repeat the chomp/print lines?".

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-16 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found