Splitting and comparing file names



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

The existing script will run localling on a each of three servers and
post to a SAN location. (various reasons why we couldn't use rsh or
ssh from a central resource to gather this data...grrrr)

The idea now is to read in each of the file names, generate a mean
(meanval = (val1+val2+val3)/3) and then compare the mean between the
three systems to determine the server with the lowest average load for
the past 15 minutes. I'm at the point where I'm not sure exactly how
to manage the split and then be able to run equations against the
values. Here's what I have so far to pull in the file to an array.
Perhaps there is a more efficient method of gathering that information
as well...

#!/usr/bin/perl

use strict;
use warning;

my ($hostname, $val1, $val2, $val3, $filename, @filesfound);

chdir ("/store/admin/tools/load");
opendir (DIR, "/store/admin/tools/load") || die "Directory not
found or unable to be opened. $!\n";
@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) {
# This is where I'm having the major issue with my own
logic...
# I probably have myself going down a bad path :p
};

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

.



Relevant Pages

  • [NEWS] IBM Informix Web DataBlade Local Root by Design
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... that ease development of "intelligent", interactive, Web-enabled database ... person who has access to change the Perl script. ...
    (Securiteam)
  • my perl script for ripping mp3s...aka MP3scRIPt
    ... This is a Perl script to convert audio cd tracks to mp3s. ... Possibly root privs to access the cdrom device ... - this is mainly a problem on 'variety cds', mp3 files suffering from this ill ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Perl script to mimic uniq
    ... mdfoster44@netscape.net spits TOFU in my face: ... > # Perl script to find most common CS ... > So I'm back to my original script which looks like this. ... > identify a sequence as unique. ...
    (comp.lang.perl)
  • Re: Slow Performance When Using DBI, otherwise Not
    ... If I run the same perl script on the database server itself it runs ... check versions of DBI and DBD (I greped for version on every module under ...
    (perl.dbi.users)
  • Re: Recovering from compromised system
    ... > perl script I have ever seen, and I would hate even more to learn a new ... > language to understand one script. ... That command is normal for a lot of substring functions. ... Hey, put a few lines in list_2_ck, run the perl script, cat j.ksh. ...
    (comp.os.linux.security)