home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5308 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.5 KB

  1. Path: sparky!uunet!olivea!bu.edu!bu-pub.bu.edu!jdh
  2. From: jdh@bu-pub.bu.edu (Jason Heirtzler)
  3. Newsgroups: comp.lang.perl
  4. Subject: perl sort bug on Irix?
  5. Message-ID: <93641@bu.edu>
  6. Date: 14 Aug 92 00:47:09 GMT
  7. Sender: news@bu.edu
  8. Organization: Boston University, Information Technology
  9. Lines: 53
  10.  
  11. Perl's sort seems to behave oddly on Irix.  What I would like
  12. to do is an inverse sort based on the length.  Is this program
  13. correct perl (ie. not some implementation dependant thing?)
  14.  
  15.   #!/usr/local/bin/perl --    # -*-Perl-*-
  16.  
  17.   push( @dirs, "usr" );
  18.   push( @dirs, "usr/bin" );
  19.   push( @dirs, "usr/bin/X11" );
  20.   push( @dirs, "usr/lib" );
  21.  
  22.   @crud =  sort {length($a) < length($b);} @dirs;
  23.  
  24.   foreach $p ( @crud ) {
  25.       print "$p\n";
  26.   }
  27.  
  28. It seems to work okay on sun4 SunOs-4.1:
  29.  
  30.   sun% ./sorter
  31.   usr/bin/X11
  32.   usr/bin
  33.   usr/lib
  34.   usr
  35.  
  36. But fails on the sgi irix 4.0.{1,5}:
  37.  
  38.   sgi% ./sorter
  39.   usr/bin
  40.   usr/lib
  41.   usr/bin/X11
  42.   usr
  43.  
  44. It behaved the same odd way on patch level 19, but this
  45. is patch level 35:
  46.  
  47.   % perl -v
  48.  
  49.   This is perl, version 4.0
  50.  
  51.   $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
  52.   Patch level: 35
  53.  
  54. What is the appropriate way to do the same sort on previous
  55. releases?  At patch level 10 perl bawks at the sort syntax
  56. (guess it's new syntax.)
  57.  
  58.  
  59. ----------------------------------------------------------------
  60. Jason Heirtzler      1-617-353-2780            jdh@bu-pub.bu.edu
  61. Sci Comp & Vis       Information Technology    Boston University
  62.  
  63. "Congratulations.  You aren't running Eunice."
  64.