Code Comments
Programming Forum and web based access to our favorite programming groups.tc314@hotmail.com wrote: > On Mar 30, 10:57 pm, kra...@telus.net (John W. Krahn) wrote: > > I'm looking for the perl way of comparing strings. > > Your posted code 'diff says memory exhausted need help with perl > Options' > is the basis I want to build from. > But it appears the gt,eq,lt comparisons ignore the hyphens in the > strings. No they do not. > I really want to avoid slowing things to a crawl by doing brute force > byte comparisons rather than string compares. Perl's string comparison operators *do* compare each byte. > (I'm really looking for a minimal patch to your code to produce the > desired results.) perldoc -q "How do I handle binary data correctly" perldoc perllocale John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall
Post Follow-up to this messagetc314@hotmail.com schreef: > John W. Krahn: > > I'm looking for the perl way of comparing strings. > > Your posted code 'diff says memory exhausted need help with perl > Options' Maybe your shell requires dquotes? -- Affijn, Ruud "Gewoon is een tijger."
Post Follow-up to this messageOn Mar 29, 3:19=A0pm, kra...@telus.net (John W. Krahn) wrote: > tc...@hotmail.com wrote: > > Please provide an *example* of your data, what it would look like if > sorted "properly", and what it actually looks like after being sorted. > > John > -- > Perl isn't a toolbox, but a small machine shop where you > can special-order certain sorts of tools at low cost and > in short order. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- =[/color ] Larry Wall Given my data: (echo.txt) 21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08-J I want perl (and linux sort) to see its order as: 08-J 08E 08F 08G 08GA 08H 2-2A 2-3A 2-4A 21A 22A 23A However (on my system): 1) linux sort: sort echo.txt produces the undesired result: 08E 08F 08G 08GA 08H 08-J 21A 22A 2-2A 23A 2-3A 2-4A 2) linux sort with -n: sort -n echo.txt produces the undesired result: 2-2A 2-3A 2-4A 08E 08F 08G 08GA 08H 08-J 21A 22A 23A 3) perl's sort produces the DESIRED result perl -le'@x =3D qw[21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08- J]; print for sort @x' 08-J 08E 08F 08G 08GA 08H 2-2A 2-3A 2-4A 21A 22A 23A So, how do I write a perl script to use in place of linux sort since perl's sort produces the desired results? I want perlsort to accept input from STDIN or a filename as an argv. I don't care about any command line options since perl seems to do exactly what I desire. (I thought perl's comparisons were wrong because I used files sorted by linux sort, my mistake.) My files are significantly larger than physical memory. Any help is appreciated.
Post Follow-up to this messageLC_ALL=C sort echo.txt tc314@hotmail.com wrote: > On Mar 29, 3:19 pm, kra...@telus.net (John W. Krahn) wrote: > > > Given my data: (echo.txt) > 21A > 22A > 2-4A > 2-2A > 23A > 2-3A > 08E > 08F > 08G > 08GA > 08H > 08-J > > I want perl (and linux sort) to see its order as: > 08-J > 08E > 08F > 08G > 08GA > 08H > 2-2A > 2-3A > 2-4A > 21A > 22A > 23A > > However (on my system): > 1) linux sort: sort echo.txt > produces the undesired result: > 08E > 08F > 08G > 08GA > 08H > 08-J > 21A > 22A > 2-2A > 23A > 2-3A > 2-4A > > 2) linux sort with -n: sort -n echo.txt > produces the undesired result: > 2-2A > 2-3A > 2-4A > 08E > 08F > 08G > 08GA > 08H > 08-J > 21A > 22A > 23A > > 3) perl's sort produces the DESIRED result > perl -le'@x = qw[21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08- > J]; print for sort @x' > 08-J > 08E > 08F > 08G > 08GA > 08H > 2-2A > 2-3A > 2-4A > 21A > 22A > 23A > > > So, how do I write a perl script to use in place of linux sort since > perl's sort > produces the desired results? > > I want perlsort to accept input from STDIN or a filename as an argv. > I don't care about any command line options since perl seems to do > exactly > what I desire. (I thought perl's comparisons were wrong because I used > files sorted > by linux sort, my mistake.) > > My files are significantly larger than physical memory. > > Any help is appreciated. > > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.