Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: chop vs chomp

by Chady (Priest)
on May 11, 2007 at 12:10 UTC ( #614884=note: print w/replies, xml ) Need Help??

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

I'm sorry to say this, but... if you were writing Perl in Perl, setting $/=";" is the fastest way to prove yourself unsuited to this task. not chomp.

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
Chady |
Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.

Replies are listed 'Best First'.
Re^4: chop vs chomp
by Moron (Curate) on May 11, 2007 at 13:25 UTC
    Only at a lower level in the sense that $/ doesn't actually help anything if you wrote it properly with a lexical analyser. But you are clearly not up to the level of seeing that with a lexical analyser in play, you really don't want chomp() in there either and so all things considered...

    Yes, I agree, you should be sorry for your arrogance.


    ^M Free your mind!

      You persist in raising the strawman of using chomp on non-record oriented input. Yes, if you've got non-line oriented files you shouldn't be trying to process it line-by-line and using chomp. And if you look you'll find that probably most of the regulars telling you you're off your chum are the first to, for instance, point someone at HTML::TokeParser when someone's attempting to treat HTML as line oriented input.

      However if you persist in insisting that a sawzall is all you ever use and that everyone else is wrong in not using them as well for everything they might be doing as well (vascular surgery, engine maintenence, animal husbandry) you can't expect to be taken seriously.

      Update: Changed first "non-line oriented" to the more generic "non-record oriented".

        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!

      I downvoted you for attacking me, instead of talking about what I wrote in my post.

      My point is, which you clearly don't want to see given that so many others have been trying to uselessly make you understand, is that you are micro-managing a feature, that YOU yourself created, because it doesn't fit your original design, and instead of admitting that your original design is flawed because it is based on some wild assumption, you still insist on generalizing that the feature is wrong to use in all other situations.

      I was going to come up with an alternative example, but shmem already gave an excellent one (the one about autovivification).

      Now let's please hear about how stupid I am, and how much I'm still lacking in knowledge about all this "computer" stuff... oh.. and about my bad english too.

      He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
      Chady |
      Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.
        It took me a while to find that auto-viv issue and I was pretty annoyed to find that it was OT after all.

        ^M Free your mind!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://614884]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-05-22 03:11 GMT
Find Nodes?
    Voting Booth?