in reply to Reading from ls-lrt (was: Reading)
(it's pretty simple code, but I'm trying different styles :)#!/usr/bin/perl sub getlast5 { my $dir=shift; my @files; opendir DIR,$dir || die "Couldn't open '$dir': $!"; for my $x (sort { (stat($b))[9] <=> (stat($a))[9] } readdir DIR) { next if $x eq "." || $x eq ".."; push @files,$x; last if $#files==4; } closedir DIR; @files; } print join("\n",getlast5(".")),"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(ichimunki) suggestion regarding Perl-ized 'ls -lrt'
by ichimunki (Priest) on Feb 05, 2001 at 20:53 UTC | |
by mr.nick (Chaplain) on Feb 05, 2001 at 20:55 UTC | |
by ichimunki (Priest) on Feb 05, 2001 at 20:59 UTC | |
|
Re: Re: Reading
by mkmcconn (Chaplain) on Feb 06, 2001 at 05:11 UTC |