>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) :
Check out perldoc sort and perldoc substr. I think this will do what you
want
@sorted = sort {
$aname = (split /\s+/, $a)[-1];
$bname
Here is a shot using map:
my @UnSorted = ();
$UnSorted[0] = '-rw--- 1 lward mail0 May 24 15:43 lward';
$UnSorted[2] = '-rw--- 1 ohara mail 8303 May 24 15:42 ohara';
$UnSorted[1] = '-rw--- 1 draymail0 May 24 15:42 dray';
foreach $alt (sort {$a->[1] cmp $b->[1] }
On May 24, Jeff Pinyan said:
>Now the GRT looks like:
>
> @sorted =
>
># get rid of leading sorting string
>map { s/^\S+\s+// }
That should be
map { s/^\S+\s+//; $_ }
or even
grep { s/^\S+\s+// }
You can use grep() here since all lines will match that regex.
--
Jeff "jap
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 mail0 May 24
On May 24, Gustho said:
>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 mail0 May 24 15:43 lward
>-rw