and we can use the _ handle to avoid stat'ing twice.

Sorry,I don't know what is _ handle.Who help explain with it please,thanks.

-----Original Message-----
From: "Randal L. Schwartz" <merlyn@stonehenge.com>
Sent: Dec 14, 2005 11:56 PM
To: beginners@perl.org
Subject: Re: sort files by creation time

>>>>> "Todd" == Todd W <[EMAIL PROTECTED]> writes:

Todd> my @files = map $_->[0],
Todd>      sort { $b->[1] <=> $a->[1] }
Todd>      map [ $_, -M ],
Todd>      grep -f,                 # get only plain files
Todd>      glob("/mnt/qdls/MSDSIN/*");

Since the map can also serve as a grep, and we can use the _ handle
to avoid stat'ing twice, this can be simplified to:

my @files =
  map $_->[0],
  sort { $b->[1] <=> $a->[1] }
  map { -f $_ ? [$_, -M _] : () }
  glob "...";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to