Hi all,
I have a perl script that searches through files in a directory, and creates an array based on that information.
After the array is created, I sort the data based on one of the variables:
@av_sorted=sort { $av_data{$a} <=> $av_data{$b} } %av_data;
Then I put all of the data into a variable, which can be printed:
foreach (@av_sorted) {
if ($av_data{$_} ne "" {
$servername=$_;
$avdata=$av_data{$_};
$html_output.=&html_servers_td();
$html_output.=$deathfile{$_};
$html_output.=&html_avdata_td();
}
}
The problem I have is that I want to pull out only the top 20 entries from the array. I thought I could do it by changing the foreach line to:
foreach (@av_sorted[0..19) {
But no data is returned, when I add that line. I don't get any errors, but no data is returned.
I didn't want to post the whole script here, as it is rather long, but if you need more information to assist me, I would be happy to post it all.
What would be the best way to pull out just the top 20 entries?
I have a perl script that searches through files in a directory, and creates an array based on that information.
After the array is created, I sort the data based on one of the variables:
@av_sorted=sort { $av_data{$a} <=> $av_data{$b} } %av_data;
Then I put all of the data into a variable, which can be printed:
foreach (@av_sorted) {
if ($av_data{$_} ne "" {
$servername=$_;
$avdata=$av_data{$_};
$html_output.=&html_servers_td();
$html_output.=$deathfile{$_};
$html_output.=&html_avdata_td();
}
}
The problem I have is that I want to pull out only the top 20 entries from the array. I thought I could do it by changing the foreach line to:
foreach (@av_sorted[0..19) {
But no data is returned, when I add that line. I don't get any errors, but no data is returned.
I didn't want to post the whole script here, as it is rather long, but if you need more information to assist me, I would be happy to post it all.
What would be the best way to pull out just the top 20 entries?