Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^6: chop vs chomp

by Moron (Curate)
on May 14, 2007 at 09:58 UTC ( #615259=note: print w/replies, xml ) Need Help??

in reply to Re^5: chop vs chomp
in thread chop vs chomp

It's narrower than that: the only situation where it is reasonable to use chomp() is where:

1) the format of the records is delimited rather than fixed width.

2) the absence of a trailing line terminator on the last line is permissible; usually because the file has been manually created.

3) the only whitespace permitted at the end of the line is the carriage return - otherwise you wouldn't do it, you'd pattern-match.

(Update: I mean of course to say: where all three conditions apply rather than just a subset of them)

Such conditions are clearly exceptional rather than the rule, yet replies to this thread confirm my suspicion that people tend to assume their use of chomp() can be assumed as being in response to a "normal" textfile case.


^M Free your mind!

Replies are listed 'Best First'.
Re^7: chop vs chomp
by eric256 (Parson) on May 14, 2007 at 14:49 UTC

    They aren't the exception for everyone. In fact 1,2,3 are normaly true for any project i'm working on.

    Eric Hodges
      1&&2&&3 or 1||2||3 ?

      ^M Free your mind!

        All three, true, at the same time. In fact I can only think of one case where all three weren't true, and in that case I was using a module anyway because it is fixed with data.

        Eric Hodges
          A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-08-18 06:43 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (185 votes). Check out past polls.