> On Wed, Jan 14, 2004 at 06:22:58PM -0700, Jose Malacara wrote:
>> Can someone explain to me how to do multiline matching? I am trying to
>> extract three consecutive lines from a datafile containing multiple
>> records like this:
>>


Hi All well i was reading through and i have a similar problem
i have code that "works" but its all slow and nasty =(
wonder if any one can help...
the data is stored in a text file in the format below,
we could have up to 40000 entry's so its a big file (but running on a E450
with 4Gig ram so ;) )
the number of lines can vary but will always start with...
segment "name" {
agentAddress     "IP"
more "info"
}

any (semi constructive) ideas suggestions welcome

RichT

database format-------------------------------------
    segment "Birmingham-WAN0" {
        agentAddress     "127.0.0.1"
        uniqueDeviceId   "SomeHeXNumbers (123445)"
        mibTranslationFile "ciscoMib2.mtf"
        index            "2"
        parentName       "Birmingham-RH"
        deviceSpeed      "64000.0"
        deviceSpeed2     "128000.0"
        discoverMtf      "ciscoMib2.mtf"
        community        "SupperPassword"
        sysDescr         "long text telling you the Cisco ver"
        sysName          "ThisOniSTheRouterName"
        sysLoc           "Birmingham"
        ifDescr          "Serial0"
        ifType           "frame-relay"
        aliasName        "Cust12345"
        nmsName          "Birmingham-WAN0"
        nmsKey           "ThisOniSTheRouterName link Serial0"
        enterpriseId     "9"
        possibleLatencySources "concord, ciscoPing"
        fullDuplex       "1"
        mediaSpeed       "128000.0"
        mediaSpeed1      "128000.0"
        statistics       "1"
    }
End The database format is like this -------------------------------------


My Current code ----------------------------------------------
sub checkResults {
my($NH_HOME,$i,@pollerCfgLine,@foundElements)=("/nethealth1","0","","");
#setup main vars
my($elementName,$elementSpeed,$elementRouterName,$elementAlias,$elementIP,$elementMIB);
# setting up names from poller
my($siteIPAdd)=$_[0];
open(POLLER, "$NH_HOME/poller/poller.cfg")|| die "can not open : $!"; #
open poller.cfg file , inport and close
my(@pollerCfg)=<POLLER>;
close POLLER;
foreach (@pollerCfg) {  #start main loop throught all poller cfg lines
        @pollerCfgLine=split(/"/,$_,3); #"split up type / value
        if ($pollerCfgLine[0] =~ /^ +segment/) {  #if we are on first line for
element key word "segment"
                $elementName=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +agentAddress/){
                $elementIP=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +mibTranslationFile/){
                $elementMIB=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +deviceSpeed2/){
                $elementSpeed=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +sysName/){
                $elementRouterName=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +aliasName/){
                $elementAlias=$pollerCfgLine[1];
        }elsif ($pollerCfgLine[0] =~ /^ +\}$/){
          if ($elementIP eq $siteIPAdd) {
                
$foundElements[$i]=("$elementName,$elementSpeed,$elementRouterName,$elementAlias,$elementMIB\n");
                $i++;
          }
                
($elementName,$elementSpeed,$elementRouterName,$elementAlias,$elementIP,$elementMIB)=("","","","","","");
        }
}

open(DISCOVERLOG, ">>tmp/discover.log.csv");
print DISCOVERLOG
"elementName,elementSpeed,elementRouterName,elementAlias,elementIP,elementMIB\n";
print DISCOVERLOG "@foundElements\n";

}

End My Current code ----------------------------------------------




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to