[EMAIL PROTECTED] writes:

>   I am curious: If that Perl code was optimized for education (as opposed to
> source size), what would it look like?

I dunno, maybe something like this:

#!/usr/bin/perl

@lines = <>;
@sortedLines = sort { 
                 ($baseA) = $a =~ m#/([^/]*)$#;
                 ($baseB) = $b =~ m#/([^/]*)$#;
                 $baseA cmp $baseB 
               } @lines;

for $line (@sortedLines) {
  print $line;
}

__END__


OBTW, while I appreciate Erik's effort (because, in fact, I am
learning Python), in actuality, I believe that his program contains a
bug: what happens if more than one file has the same basename, for
example:

        /a/a/a/a/a/a/a/a/blah
        /b/b/b/b/b/b/b/b/blah

While Erik's program "doesn't suck", and while it does look nice, I
don't believe that it handles this case.

None of the solutions that I have posted suffer from this bug, BTW.

Regards,

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc


_______________________________________________
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

Reply via email to