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?".
|
|---|