Re: Splitting and comparing file names



In article <1166114810.087246.179750@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Jake" <Jake.Newly@xxxxxxxxx> wrote:

Thanks to some help on another thread I have a perl script that will
generate a file in the following format:

hostname#val1#val2#val3.load

....
@filesfound = sort (grep (/\.load$/, readdir(DIR)));
if ( ! @filesfound) {
die ("None of the load files were found. Please verify that
the writeLoad.pl script is running properly. $!\n");
closedir(DIR);
}
else {
foreach $filename(@filesfound) {

# insert something like this:
use List::Util qw(sum); # normally put near the top.

$filename =~ s/.load$//;
my($host, @times) = split '#', $filename;
my $avg = sum(@times) / (scalar @times); # @times would work,
# but scalar guarantees the number of elements.

};

Any ideas would be great. Keep in mind that I'm not a developer and
I'm sitting down with perl books and the internet to try to figure this
out. :)

At the moment I'm trying to read through and find information for
manipulating array data and I must admit that I'm just not getting it
yet.

Jake

Boyd
.