At 05:59 PM 5/24/01 -0400, Gustho wrote:
>Below is a sample directory listing of the mail folder
>on a Linux box, I would like to sort the same using
>the last field (ie. lward, ohara, dray) starting with
>the 2nd character (ie from ward , hara and ray) :
>
>-rw------- 1 lward mail 0 May 24 15:43 lward
>-rw------- 1 ohara mail 8303 May 24 15:42 ohara
>-rw------- 1 dray mail 0 May 24 15:42 dray
>
>Any Suggestions would be greatly appreciated. TIA
my $directory = shift;
@lines = `ls -l $directory`;
shift @lines; # Total...
@lines = sort { substr((split /\s+/, $a)[8],1) cmp substr((split /\s+/,
$b)[8],1) } @lines;
print @lines;
Yeah, it's not as efficient as it could be, but you won't notice that
unless your directories contain more than ten thousand entries or you're
running on a 386...
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com