Hi all well im trying at lerning this perl stuff.. reading from the "learning perl" oreilly book and a few other places, but also using perl a long time before i should ie making the below script, so that i dont get in to any very bad habbits at such an early stage. could some one please have a look at the code below and give comments, the code does do what i want it to ( well at leest from this stage).
#!/usr/bin/perl -w ############################################################ # this function creates a arf rule file from an input file # Version 0.1 6/11/03 ############################################################ @dataFile=<>; # read in file from command line @standardRules=`cat standard.for.arf.txt` ; foreach $site (@dataFile) { # loop for each line/site in dataFile chomp $site; ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3); #split up main / pvc info ($siteIP,$siteString,$SiteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,/,$siteLink,6); #split up main info (@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs); my $siteARFfile = "$siteIP.arf"; open(ARFfile, ">$siteARFfile") or die("can not open '$siteARFfile': $!"); print ARFfile ("###################################################################### \n# \n# Discover Rule for: $siteIP \n# \n###################################################################### \n\n"); # print header print ARFfile ("@standardRules\n"); #print standard bits print ARFfile ("name matches \".*-Cpu-.*\": {\n \tsetName (\"$SiteName-RH-Cpu\") ;\n \tsetGroup (\"$siteGroup\") ;\n \tsetAlias (\"RH-Cpu\") ;\n} \n\n" ); # print -Cpu- rule print ARFfile ("name matches \".*-RH\": { \n \tsetName (\"$SiteName-RH\") ;\n \tsetGroup (\"$siteGroup\") ; \n \t setAlias (\"RH\") ;\n} \n\n" ); # print -RH rule print ARFfile ("name matches \".*RH-Serial.*\": {\n \tsetName (\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup (\"$siteGr oup\") ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn (\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n \tsetD eviceSpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\") ;\n} \n\n"); # print RH-Serial rule print ARFfile ("name matches \".*-Serial.*\": {\n \tsetName (\"$SiteName-WAN\$2\") ;\n \tsetGroup (\"$siteGroup\" ) ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn (\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n \tsetDevice SpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\") ;\n} \n\n"); # print -Serial rule for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC ($PVCdlci,$PVCname,$PCVreff,$PVCcir)=split(/,/,"$sitePVCs[$i]",4); # split out pvc info print ARFfile ("name matches \".*-dlci-$PVCdlci\": {\n \tsetName (\"$SiteName-$PVCname\") ;\n \tsetGroup (\"$siteGroup\") ;\n \tsetAlias (\"$PCVreff\") ;\n \tsetSpeedIn (\"$PVCcir\") ;\n \tsetSpeedOut (\"$PVCcir\") ;\n \tsetDev iceSpeedIn (\"$PVCcir\") ;\n \tsetDeviceSpeedOut (\"$PVCcir\") ;\n} \n\n"); # print PVC rules } close(ARFfile) or die("can not close '$siteARFfile': $!"); } --- fnord yes im a Concord Engineer, no it never flown! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]