I would like to put the info in the rhic_au_fy01_fill[$dbEvents->ct_sql("use rhic_au_fy01_fill")] in a hash to speed up this program. I've looke at many perlfaq's, but I'm still having trouble doing correctly...
#! /usr/local/bin/perl -w # A perl program to analyze the notifAlarmLog Table and quench times use FileHandle; use IPC::Open2; use Symbol; # use Tk; use Sybase::CTlib; use Time::Local; use strict; my(%systemNames); systemNames(); # fill in the hash of PS sytem names use strict; my $dbAlarms = new Sybase::CTlib 'harmless','harmless','OPSYB1','notif +LogTable'; $dbAlarms->ct_sql("use TomTest"); my $sql = "SELECT distinct name FROM notifAlarmLog"; my(@rows,$row); @rows = $dbAlarms->ct_sql($sql); foreach $row (@rows) { $sql = "SELECT * FROM notifAlarmLog WHERE name like '$row->[0]'"; my($supply,@supplies); @supplies = $dbAlarms->ct_sql($sql); # count all alarms for each PS my $count = @supplies; # count how many alarms are 2 seconds or less for each PS? my $OneSecCount = 0; # count how many alarms are >2 and <=10 seconds for each PS? my $TwoSecCount = 0; # count how many alarms are >10 seconds for each PS ? my $TenSecCount = 0; # count how many alarms occur w/in 10 seconds after a QUENCH EVENT? my $QuenchCount = 0; foreach $supply (@supplies) { $OneSecCount++ if(($supply->[4]-$supply->[3]) <= 2); $TwoSecCount++ if(($supply->[4]-$supply->[3]) > 2 and ($supply->[ +4]-$supply->[3]) <= 10); $TenSecCount++ if(($supply->[4]-$supply->[3]) > 10); my $dbEvents = new Sybase::CTlib 'harmless','harmless','OPSYB1','f +illeventsT'; $dbEvents->ct_sql("use rhic_au_fy01_fill"); my $sql = "SELECT * FROM fillEventsT WHERE rhicTime like 'Oct%' and (event like 'ev-bquench' + or event like 'ev-yquench')"; my(@fills,$fill); @fills = $dbEvents->ct_sql($sql); foreach $fill (@fills) { # how many alarms occur w/in 10 seconds a +fter a QUENCH EVENT? # to change time of filter, change time here!!! $QuenchCount++ if(($supply->[3] - $fill->[0]) <= 10) and (($supp +ly->[3] - $fill->[0]) > 0); } } #filter out alarms that occur w/in 10 seconds after a Quench EVENT my $diff = $count - $QuenchCount; my ($f1,$adoName,$f3) = split(":",$row->[0]); my $SiteWideName = $main::systemNames{$adoName} . ":$f3"; # print ":$adoName: :$SiteWideName: \n"; print "$SiteWideName , $count , $OneSecCount , $TwoSecCount , $TenSe +cCount, $diff \n"; } sub systemNames { # fill in the systenName hash use strict; my $dbAdo = new Sybase::CTlib 'harmless','harmless','OPSYB1','notifL +ogTable'; $dbAdo->ct_sql("use serverAdo"); my $sql = "SELECT name,systemName from adoInst where name like 'psWa +tch%'"; my(@rows,$row); @rows = $dbAdo->ct_sql($sql); foreach $row (@rows) { $main::systemNames{$row->[0]} = $row->[1]; # print "<$row->[0]> <$row->[1]> \n"; } }

In reply to creating a table hash by cjacksonjr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.