> From: Vicki Brown [mailto:vlb@cfcl.com] > Sent: Thursday, June 17, 1999 23:07 > To: fwp@technofile.org > Subject: Re: [Fun With Perl] Everything should be kept as simple as > possible... > > At 20:13 -0400 06/17/1999, Steve Willer wrote: > >What is wrong with this? > > > > cat names.txt|sed 's/||/, /g'|sort +0 +1 > > It's a Perl list :-) > > Maybe he wanted something as part of other code... > Maybe he's not on Unix (the question did come from the > MacPerl list :-) > > >there's someting to be said for a nice, simple pipe. My single-line pipe > >does a more correct sort than the perl equivalents you posted because it > >sorts last name before first, rather than sorting the line as a whole. > > Given that the result is the same... why is this "more correct"? :) Unfortunately, the result is *not* the same. You, and your reviewers, MJD and Randal, have completely missed the point (and missed the boat). Because of the position of the last-name delimiter '|', in the ASCII character set, any pair of lines for which the first fields (the last names) are identical except that one is a leading substring of the other will sort in the wrong order. print sort "John||Elton\n", "Johnson||Lyndon\n"; Shame on all of you! :-) Everything should be kept as simple as possible... but no simpler. Use the Schwartz, Randal et al! -- Larry Rosler Hewlett-Packard Company http://www.hpl.hp.com/personal/Larry_Rosler/ lr@hpl.hp.com ==== Want to unsubscribe from this list? (Don't you love us anymore?) ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org