[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Ordering two lists



At 11:17 +0100 2000.12.09, Giorgio Valoti wrote:
>Chris Nandor wrote:
>>
>> At 10:38 +0100 2000.12.07, Giorgio Valoti wrote:
>> >Hi all!
>[....]
>>
>> You could use a hash.
>>
>> my %hash;
>> for my $file (readdir DIR) {
>>         $hash{$dir . ':' . $file} = int -M $file;
>> }
>>
>> for my $file (sort { $hash{$a} <=> $hash{$b} } keys %hash) {
>>         print "$hash{$file} : $file\n";
>> }
>
>Yes, that's right... however I think there's a typo: with the code
>fragment above we should have:
>
>my $fileName =  $dir . ':' . $file;
>
>and use this variable to get the last modification.

I normally would do a chdir() when I do an opendir() so I don't have to
bother with appending the directory to get info about a file; if I had more
than a fragment, that would have been in there.  If you don't chdir(), then
yep, you need that.

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org