Richard Lee wrote:
Richard Lee wrote:
stion on this.. suppose there is 3 files in temp directory
/tmp/yahoo1
/tmp/yahoo2
/tmp/yahoo3
and I wanted to take the last file that was created.. would this work?
my $filename = shift;
my @file_1 = </tmp/$filename*>;
my $file_1 = $file_1[-1];
push @files, $file_1;
i am not 100% sure if this logic is correct or not.
my %big_hash;
for (@file_1) {
$big_hash{$_} = (stat($_))[9];
}
my @keys = sort { $big_hash{$a} <=> $big_hash{b} } keys %big_hash;
my $file_1 = $keys[-1];
push @files, $file_1;
I am missing a $ in $big_hash{b}.. and i see that this method works..
but is there easier and better(correct) way to do this ???
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/