Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Odd workings of split

by Anonymous Monk
on Mar 29, 2012 at 13:03 UTC ( #962383=note: print w/ replies, xml ) Need Help??

in reply to Odd workings of split

It seems odd that, if what you want to do is to "remove newlines," that you do not use the obvious regex to do that.   If you want to "take the command up to the first newline if any," split will work fine, in a short subroutine, with an if-statement to supply an empty-string for undef.   Two (gasp!) lines of code ... problem solved.

Comment on Re: Odd workings of split
Replies are listed 'Best First'.
Re^2: Odd workings of split
by Ralesk (Pilgrim) on Mar 29, 2012 at 13:08 UTC

    Sometimes Iím in a regexy mood and would do a lot of things with regexes ó I was feeling oddly anti-regex when I wrote this and hence my preference to splitís 0th result. Itís also anÖ obvious way, I guess :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-11-25 23:41 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (693 votes), past polls