Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > "chomp,chop" usage i.e. chop immediately after chomp

Reply
Thread Tools

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

 
 
martin
Guest
Posts: n/a
 
      04-15-2006
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

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      04-15-2006
martin wrote:
> 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


 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-15-2006
martin <(E-Mail Removed)> wrote:
> 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.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      04-15-2006
martin wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chop vs Chomp zoomcart.com Perl Misc 4 04-02-2008 01:19 AM
chop and chop! Johnathan Smith Ruby 2 01-08-2008 04:54 PM
I'm lazy: how do I make the first databound record not display/chop off the first element from SqlDataSource ASP .Net 7 06-28-2006 10:24 AM
print chop; VS chop; print; yusufm Perl Misc 2 03-09-2006 12:29 AM
Inverse of 'chop @array' gusmeister Perl 1 03-06-2004 01:28 AM



Advertisments