On Fri, Oct 06, 2000 at 11:59:31AM -0600, Sean M. Burke wrote:
> The current behavior makes trailing empty fields non-existent, and that's a
> bizarre and nonintuitive thing to have be a default; if your code relies on
> them being removed, then remove them explicitly, without expecting split to
> do it for you /by default/ at the expense of all the people who would
> expect a saner and less surprising default.
How many people has this bitten? One of the reasons for these
default behaviors is that they are *useful* defaults.
> If you want trailing/leading/all nulls removed without having to type the
> single line of code it'd take to do it explicitly, then have that be an
> option to split; don't have it be a default.
I'm all for being explicit, but I've come to rely on many of the
little short-cuts like this that perl provides. Making it some sort
of option to split forces verbosity where I'm used to terseness.
> >Makes it harder on one liners.
> >
> > split; shift;
>
> ...assuming that your one-liner happens to want to do exactly what the
> defaults are
Well, of course! Surely the author knows what they are doing?
> to say nothing of anyone who has to make sense of your one-liner.
You're right about this though. The author may know what they wrote
but the reader doesn't necessarily know what it means without using a
reference of some sort. But what happens when you're reading a book
and a familiar word is used in a context you've never seen before?
Don't you look up alternate definitions for that word in a dictionary?
> (This is as opposed to all the people who do not know that split(X, Y,
> -1) is the way to get it to stop deleting trailing empties, and cannot
> be reasonably expected to guess something so obscure.)
Why guess when there is a wealth of documentation?
Well, I started this message half-way agreeing with you but as I
re-read what I've written, it looks like I've excised all of the parts
where I wanted to say "I agree" because I think I agree in principle
but not in actual. (I do agree in actual with annoyances 3 and 4 of
your RFC however)
Anyway, here's a look at what would be common idioms if your version
of split() were adopted:
@foo = split;
# BECOMES
@foo = split; pop @foo until $foo[-1];
@foo = split ' ';
# BECOMES
@foo = split /\s+/; shift @foo;
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]