"chomp,chop" usage i.e. chop immediately after chomp

M

martin

Hi, I have been reading the postings on chopm and chop. I am wondering
if one would use

while <INPUTFILE>
chomp;chop;
.....
....

what is the use of this, doesn't chomp already remove the end of line
delimiter whatevere that happens to be.


Thanks, Martin
 
J

Jürgen Exner

martin said:
Hi, I have been reading the postings on chopm and chop. I am
wondering if one would use

while <INPUTFILE>
chomp;chop;

Well, sure, if for some odd reason you want to remove the last character of
the string...
what is the use of this,

Nothing particularly useful.
doesn't chomp already remove the end of line
delimiter whatevere that happens to be.

Yeah, but chop() removes any trailing character, not just a \n.

jue
 
T

Tad McClellan

martin said:
Hi, I have been reading the postings on chopm and chop. I am wondering
if one would use

while <INPUTFILE>


Please do not post pseudocode, post real Perl code, with parenthesis
and curlies and whatnot.

chomp;chop;
what is the use of this,


It removes the line ending sequence if one is present, and then
removes one more character from the end of $_.

ie. it doesn't appear to be of much general use at all.

doesn't chomp already remove the end of line
delimiter whatevere that happens to be.


Yes. (but newline is not a "delimiter")

Then chop() does what chop() does, namely removes whatever character
is now at the end.
 
J

Joe Smith

martin said:
Hi, I have been reading the postings on chopm and chop. I am wondering
if one would use

while <INPUTFILE> {
chomp;chop;

That only makes sense if the input file is in DOS format and being
processed on a Unix-style system. Then chomp() would remove the
"\n" and chop() would remove the "\r". There are better ways.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top