Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://615259]
help
Chatterbox?
[choroba]: :-)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-02-21 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (281 votes). Check out past polls.

    Notices?