Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Seekers of Perl Wisdom

( #479=superdoc: print w/ replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask. Post a new question!

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
Tie subroutine to a built-in function call?
2 direct replies — Read more / Contribute
by bcarroll
on Aug 23, 2016 at 12:57
    Is it possible to tie a callback/subroutine that will be automatically executed when another function/subroutine is called?

    For example: If I call the built-in open() function, it does it's thing.

    I would like to watch for calls to open() and execute my own subroutine at the same time (before or after, but automatically). Is this possible?

CSV column names
3 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 23, 2016 at 12:21

    Hi, i am making a program that queries a csv file using the DBI module, but can't find out how to get the column names. Can someone help me out. tx.

    use DBI; $dbh = DBI->connect("DBI:CSV:"); $dbh->{'csv_tables'}->{'info'}={'file'=>'info.csv'}; $qu = $dbh->prepare("SELECT * From info"); $qu->execute(); while (@row = $qu->fetchrow_array){ print "@row\n";}
Advice wanted for debugging CPAN Testers failures
3 direct replies — Read more / Contribute
by pryrt
on Aug 23, 2016 at 11:59
    Fellow Monks,

    How do you go about debugging failures from CPAN Testers when your own configurations are not failing? I'd like advice, both in general, and anything you see in my specific examples below.

    For example, this test matrix has a bunch of failures -- but when I test on my machines, I cannot replicate the errors they are getting.

    Before releasing, I tested on a couple of different versions I have access to (strawberry perl 5.24.0_64 on Win7 and an ancient CentOS 4.6 linux 2.6.9-55 with perl 5.8.5), and neither failed my test suite. And since I've seen the CPAN Testers failures, I've started increasing my berrybrew installations to improve version coverage -- but so far, they've all passed, even when they've been on Perl versions that failed in the linux column.

    After I've exhausted available Strawberry installations, I will probably grab one of my linux virtual machines and start increasing perlbrew installations, and run through as many as I can there (I cannot install perlbrew or other local perls on the CentOS machine I noted, due to disk restrictions). But even with trying a new slew of versions, I cannot guarantee that I'll see the same failures that CPAN Testers is showing me.

    I know where I'll be looking for the specific errors: my expected values are wrong; the expected values were being generated by functions I thought were fully tested earlier in my test suite, so I'll have to look into that some more, and also see if maybe I should independently generate the expected values.

    But if I cannot replicate the exact failures from CPAN Testers, it's going to be harder to know I've solved the problem. When doing my last release to add features, I ended up submitting beta versions to CPAN, with extra debug printing, and waiting overnight while the CPAN Testers ran, then basing my fixes on changes in those results. But that's a rather slow debug process... and I noticed that every submission, I was getting fewer results from TESTERS: I think some of those auto-testers have some sort of submission limits, or otherwise remember that a particular module fails and stops testing new versions.

    Any advice, generic or specific, would be welcome.

translate VB Script to Perl Script
3 direct replies — Read more / Contribute
by rameshBhupal
on Aug 23, 2016 at 11:13
    Hi, I need to translate the below VB script to Perl Appreciate your help !!
    <?xml version="1.0" standalone="yes" ?> <package> <comment><![CDATA[ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File: vnDevList.wsf Version: See WSH resource ID ATTEASE_VERSION Synopsis: Extract a list of VitalSuite Net (VitalNet) po +lled devices, write out XML file. Detailed Description 1. This script runs on the VitalNet masters. +If the present machine is not a master then exit. 2. Discover the machine's aggrs. 3. For each aggr, run the query to list the de +vice inventory as XML. Command Syntax: See <example> element, below, for all options Prerequisite: Windows 7 or later, Windows Server 2008 or later +. Notes: 1. This WSH file should be well-formed XML. Use + ValidateXml.vbs to check. 2. A DTD cannot be embedded in this file. This +is a limitation of WSH. 3. The WScript.Arguments.ShowUsage() method will + display everything within the <runtime> element. Use /? argumen +t to invoke this method. References: Windows Script Host XML format is on MSDN under + Reference (Windows Script Host) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]></comment> <job id="vnDevList"> <runtime> <!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^ ADJUST THE <description> AND <example> ELEMENTS FOR YOUR AP +PLICATION The description and example will be displayed if the /? swi +tch is entered or if the command syntax is invalid ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^ --> <description><![CDATA[Fetch VitalNet Device List]]></description +> <example><![CDATA[ [ /? ] | [ -version ] | { [ -config=(a[,b[,c...]]) ] [ "-customer=customer" ] [ -distlist=standard|alternate|default ] [ -ipaddr=vsInstallIP ] [ -mail=always|never|conditional ] [ -stats ] [ -traceLevel=n ] [ -trapError | -noTrapError ] [ -valcfg | -validateconfiguration ] }]]> </example> </runtime> <!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^ ADJUST ALL DIRECTORY PATHS FOR YOUR APPLICATION: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^ --> <resource id="ATTEASE_APPNAME">vnDevList</resource> <!-- applica +tion name --> <resource id="ATTEASE_VERSION">1.0.2</resource> <!-- applica +tion version --> <resource id="ATTEASE_HOME">.</resource> <!-- applica +tion home directory --> <resource id="ATTEASE_CONF">.</resource> <!-- applica +tion conf directory --> <resource id="ATTEASE_LIB">.</resource> <!-- applica +tion lib directory --> <!-- Configuration files in format [fileName,rootElementId,versi +on]: --> <resource id="ATTEASE_CONFIG_FILES"> [AttConfigGlobal.xml,attConfig,1.00], [AttConfigVnDevList.xml,attConfig,1.00] </resource> <resource id="ATTEASE_CONFIG_TEMPLATE">dummy.xml</resource> <!-- The following scripts are required by most applications: +--> <script language="vbscript" src="AttAdo.vbs" /> <!-- ADO cons +tants --> <script language="vbscript" src="AttApp.vbs" /> <!-- applicat +ion method dispatcher --> <script language="vbscript" src="AttCore.vbs" /> <!-- core uti +lities --> <script language="vbscript" src="AttConfig.vbs" /> <!-- configur +ation utilities --> <script language="vbscript" src="AttEmail.vbs" /> <!-- email cl +ass --> <script language="vbscript" src="AttFile.vbs" /> <!-- file man +ipulation --> <script language="vbscript" src="AttLog.vbs" /> <!-- log clas +s --> <script language="vbscript" src="AttNet.vbs" /> <!-- network + --> <script language="vbscript" src="AttSort.vbs" /> <!-- Sort rou +tine --> <script language="vbscript" src="AttWmi.vbs" /> <!-- WMI clas +s --> <script language="vbscript"> <![CDATA[ Option Explicit AttCore.requireVersion "AttAdo","1.04" AttCore.requireVersion "AttApp","1.40" AttCore.requireVersion "AttCore","1.20" AttCore.requireVersion "AttConfig","1.20" AttCore.requireVersion "AttEmail","1.08" AttCore.requireVersion "AttFile","1.04" AttCore.requireVersion "AttLog","1.07" AttCore.requireVersion "AttNet","1.04" AttCore.requireVersion "AttSort","1.01" AttCore.requireVersion "AttWmi","1.08" ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' ' Initialization ' ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' Instantiate, populate an ATTEASE object. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ AttCore.InitResources ' load WSH-defined resources into global AT +TEASE object ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' Preprocess the command line arguments to get optional custom co +nfig file names ' specified via the -config=(filename[,filename...]) option ' ^^^^^^^^^h^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^ Call AttCore.getArgumentsFiltered ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' Instantiate the configuration object ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ReDim aConfigFiles(-1) Dim configFile, aConfigFile If UBound(AttCore.getConfigFiles()) > -1 Then ' get the config fi +lenames from the command line For Each configfile In AttCore.getConfigFiles() AttCore.push aConfigFiles,Array(configfile,"attConfig","1. +00") Next Else ' take the default from the WSH resource For Each aConfigfile In AttCore.getConfFiles() AttCore.push aConfigFiles,aConfigfile Next End If AttCore.setConfig((new AttConfig).Init(aConfigFiles)) ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' Need to know if VitalNet supports new data columns for IPv6. ' This is true if VitalNet version >= 11. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ Dim bHasIPv6: bHasIPv6=True Function hasIPv6: hasIPv6=bHasIPv6: End Function ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ ' Process the command line arguments, handling nonstandard argume +nts here ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ Dim oConfig: Set oConfig=AttCore.getConfig() Dim oWatchlet: Set oWatchlet=oConfig.watchlet Dim customer: customer=AttCore.getCustomer ' must be reprocessed +after config and args are processed Dim masterIpaddr: masterIpaddr=oWatchlet.vsInstallIp Dim sCustomArg For Each sCustomArg In AttCore.getArgumentsFiltered() Select Case LCase(sCustomArg) Case Else If AttCore.strSearch(1,sCustomArg,"^[-/]ipaddr=(\S+)$", +vbTextCompare)>0 Then Dim aIpaddr: aIpaddr=Split(sCustomArg,"=") ' WScript.Echo "ipaddr=" & aIpaddr(1) masterIpaddr=aIpaddr(1) If Not AttCore.isIpaddr(masterIpaddr) Then wScript.Echo "vnDevList: invalid argument, " & m +asterIpaddr & _ ", not a valid IP address" WScript.Quit(2) End If AttCore.pushCommandArgument("Ipaddr(" & masterIpaddr + & ")") Else WScript.Echo("vnDevList: Unknown argument, " & sCust +omArg) WScript.Arguments.ShowUsage() WScript.Quit(2) End If End Select Next customer=AttCore.getCustomer ' must be reprocessed after config an +d args are processed Dim MssqlADODB: Set MssqlADODB=New MssqlADODB_ ' create connection + factory for MS SQL Server ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^ ' Instantiate the log object ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^ Set ATTEASE.LOG=(New AttLog).Init("vndevlist",True) ' message pref +ix, echo ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^ ' Execute the application's configured methods in sequence ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^ Set ATTEASE.APP=New AttApp Dim bApplRc: bApplRc=True bApplRc=ATTEASE.APP.validate() ' validate that each configured met +hod exists If bApplRc Then bApplRc = ATTEASE.APP.dispatch() Set ATTEASE.LOG=Nothing WScript.Quit(0) ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' Add extending functions here. ' ' Message range for extensions begins with 6000. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' Method buildDeviceList ' ' 1. Determine from the registry whether VitalNet is installed. Ch +eck the VN ' version. If version is < 11 then note that IPv6 is not suppor +ted. ' 2. Determine from the catalog of databases whether this is a Vita +lNet master. ' If it is not a master then exit. This logic is a subset of th +e logic for ' Vitalwatch discovery. ' 3. Discover the machine's aggrs. ' 4. For each aggr, run the query to list the device inventory ' as XML. ' ' Reserved message range: 6000-6199 ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ Function buildDeviceList() On Error GoTo 0 Dim bReturnCode: bReturnCode=True ' success Dim rc, sDescr ' return code from called functions as integer an +d as string ATTEASE.LOG.writeLine(VbCrLf & "Build VitalSuite NET Device List +") If AttCore.getTraceLevel() > 0 Then ATTEASE.LOG.writeMsg "6000","I","Start buildDeviceList at " & + AttCore.formatDate(,,Empty) End If Dim config: Set config=AttCore.getConfig() Dim watchlet: Set watchlet=config.watchlet If Watchlet Is Nothing Then getEmailSubject().addIssue("Configuration Error") ATTEASE.LOG.writeMsg "6002","C","Method buildDeviceList calle +d but no watchlet defined" buildDeviceList=False Exit Function End If ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' IPv6 is supported from VitalNet 11 on. There are new columns +that support ' IPv6. We must determine that these columns are accessible. Ch +ecking ' the version of the VN Master (this machine) should be good eno +ugh. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^ ' Check registry for VitalSuiteCommon\VitalNet. This could be i +n SOFTWARE ' branch or SOFTWARE\Wow6432Node. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^ Dim sVitalNetVersion: svitalNetVersion=Null Dim sKeyPath: sKeyPath="SOFTWARE\VitalSuiteCommon\VitalNet" Dim sErrDescr ' capture error message from VBScript Err object Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_CURRENT_CONFIG = &H80000005 On Error Resume Next Dim oLocator: Set oLocator = CreateObject("WbemScripting.SWbe +mLocator") Dim oRegSvc: Set oRegSvc = oLocator.ConnectServer(".", "root +\default") oRegSvc.Security_.ImpersonationLevel=3 Dim oReg: Set oReg = oRegSvc.Get("StdRegProv") If Err.Number<>0 Then sErrDescr=Err.Description On Error GoTo 0 Err.Raise 11111,"vnDevList","Computer '.' received error conn +ecting to registry: " & sErrDescr End If On Error Goto 0 oReg.GetStringValue HKEY_LOCAL_MACHINE,sKeyPath,"Version",sVital +NetVersion If isNull(sVitalNetVersion) Then sKeyPath="SOFTWARE\Wow6432Node\VitalSuiteCommon\VitalNet" oReg.GetStringValue HKEY_LOCAL_MACHINE,sKeyPath,"Version",sVi +talNetVersion If isNull(sVitalNetVersion) Then ATTEASE.APP.getEmailSubject().addIssue "VitalSuite Net not + installed" ATTEASE.LOG.write(" ").WriteMsg "6018","E","VitalSuite Ne +t not found in Windows registry, exiting" buildDeviceList=False Exit Function End If End If 'sVitalNetVersion="10.9.9.9" 'WScript.Echo(sVitalNetVersion) bHasIPv6= (AttCore.cmpVersion(sVitalNetVersion,"11") >= 0) ' ver +sion 11 is required for IPv6 support 'WScript.Echo "HasIPv6=" & hasIPv6() 'WScript.Quit(0) ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^ ' Discover VitalSuite features - NET master, aggr, poller, VS rep +orting ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^ ATTEASE.LOG.write(" ").writeMsg "6020","I","Discovering VitalSui +te NET features" Dim mssqlServer: mssqlServer=masterIpaddr Dim oCon: Set oCon=MssqlADODB.connect(mssqlServer) If oCon Is Nothing Then ATTEASE.APP.getEmailSubject().addIssue "ADODB connection open + failed" ATTEASE.LOG.write(" ").WriteMsg "6022","E","ADODB connection + open to "& mssqlServer & " failed for reason: " & MSsqlADODB.errstr buildDeviceList=False Exit Function End If Dim oRst: Set oRst = CreateObject("ADODB.Recordset") ' Database initialization is done. ' Discover the VitalSuite databases on this machine: ' VitalSuite databases found: Dim bDbVNMaster: bDbVNMaster=False Dim bDbVNAggr: bDbVNAggr=False Dim bDbVNPoller: bDbVNPoller=False Dim bDbVSReports: bDbVSReports=False ' Vital Real-Time Dim bHasRT: bHasRT=False ' Discover the VitalSuite databases on this machine: On Error Resume Next ' In VBScript tristate logic, -1 is vbTrue and 0 is vbFalse oRst.Open "select case when DB_ID(N'VNMaster') is null then 0 els +e -1 end as hasVNMaster, " & _ "case when DB_ID(N'VNAggr') is null then 0 else +-1 end as hasVNAggr, " & _ "case when DB_ID(N'VNPoller') is null then 0 els +e -1 end as hasVNPoller, " & _ "case when DB_ID(N'VSReports') is null then 0 el +se -1 end as hasVSReports", oCon If Err.Number <> 0 Then sErrDescr=Err.Description On Error GoTo 0 ATTEASE.APP.getEmailSubject().addIssue "Query open for databa +ses failed" ATTEASE.LOG.WriteMsg "6030","E","ADODB Query open for discove +ring databases failed for reason: " & sErrDescr buildDeviceList=False Exit Function End If On Error Goto 0 bDbVNMaster=oRst("hasVNMaster").Value bDbVNAggr=oRst("hasVNAggr").Value bDbVNPoller=oRst("hasVNPoller").Value bDbVSReports=oRst("hasVSReports").Value oRst.Close ' Create set of databases discovered on this host: Dim aDbSet: aDbSet=Array( _ Array("VNMaster",bDbVNMaster), _ Array("VNAggr",bDbVNAggr), _ Array("VNPoller",bDbVNPoller), _ Array("VSReports",bDbVSReports) _ ) ' Document the discovered databases; Dim aDb ReDim dbList(-1) For Each aDb In aDbSet Dim sDB,bHasServerRole: sDb=aDb(0): bHasServerRole=aDb(1) If bHasServerRole Then AttCore.push dbList,sDb Next ATTEASE.LOG.write(" ").writeMsg "6032","I","VitalSuite databas +es are " & Join(dbList,", ") ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^ ' If this machine does not have a VNMASTER database, stop here. +This is ' not a VitalSuite Net master. Signal success anyway, since this ' is not a script error. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^ If Not bDbVNMaster Then ATTEASE.LOG.write(" ").writeMsg "6040","I","This host is no +t a VitalSuite NET master. " & _ "Device list will not be ge +nerated." buildDeviceList=True Exit Function End If ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^ ' Discover aggrs for this master. ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^ ATTEASE.LOG.write(" ").writeMsg "6050","I","Discovering VitalSui +te NET Aggrs" ' Track the IP addresses of the peer network devices so that we c +an eliminate duplicates ' Map address->aggrID Dim dictAggr: Set dictAggr = CreateObject("Scripting.Dictionary") Dim oNetDevice,oInterface ' temporary variables ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^ ' Find all the aggr machines for this master (including this mach +ine) ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^ ' bDbVNMaster=oRst("hasVNMaster").Value ' bDbVNAggr=oRst("hasVNAggr").Value ' bDbVNPoller=oRst("hasVNPoller").Value On Error Resume Next oRst.Open "select AggrID, AggrName, AggrAddress, AggrStatus " & +_ " from VNMaster.dba.VnAggrTable" & _ " where AggrAddress > ''" & _ " order by AggrID", oCon,adOpenForwardOnly,adLockReadO +nly,adCmdText If Err.Number Then sErrDescr=Err.description On Error GoTo 0 Err.Clear buildDeviceList=False ATTEASE.APP.getEmailSubject().addIssue "Query for aggrs faile +d" ATTEASE.LOG.writeMsg "6054","E", _ "ADODB Query open for aggrs failed for r +eason: " & sErrDescr Exit Function End If On Error GoTo 0 Dim iTotalVitalnetAggrsRead: iTotalVitalnetAggrsRead=0 Do Until oRst.EOF iTotalVitalnetAggrsRead = iTotalVitalnetAggrsRead + 1 If False Then WScript.Echo " AggrID=" & oRst("AggrID").Value & _ ", AggrName=" & oRst("AggrName").Value & _ ", AggrAddress=" & oRst("AggrAddress").Value & + _ ", AggrStatus=" & oRst("AggrStatus").Value End If ' net device requires label, active attributes If dictAggr.Exists(oRst("AggrAddress").Value) Then ' WScript.Echo(" already have IP address " & oRst("AggrAd +dress").Value) ElseIf oRst("AggrStatus").Value=0 Then ' WScript.Echo(" IP address " & oRst("AggrAddress").Value + & " has AggrStatus of 0, will not be used") Else dictAggr.Add oRst("AggrAddress").Value,oRst("AggrID").Value End If oRst.MoveNext Loop oRst.Close Set oRst=Nothing oCon.Close Set oCon=Nothing ATTEASE.LOG.Write(" ").writeMsg "6060","I", _ "Aggrs are: " & Join(dictAggr. +Keys,", ") Dim outFilename: outFilename="vndevlist_" & masterIpaddr & ".xml +" outFilename=config.emailMailbag() & "\" & outFilename ATTEASE.LOG.write(" ").writeMsg "6100","I","Writing to file " & + outFilename & " at " & _ AttCore.formatDate(,,Empty) On Error Resume Next Dim oStream Set oStream=AttFile.AttFileFSO.OpenTextFile(outFilename, _ AttFileOpenForWritin +g, _ True, _ False) If Err Then Dim desc: desc=Err.description On Error GoTo 0 Err.Raise 11111,"vnDevList.buildDeviceList","File " & outFile +name & " cannot be opened for output: " & desc End If On Error GoTo 0 oStream.WriteLine "<?xml version=""1.0"" standalone=""yes"" ?>" oStream.Writeline "<vnDevList customer=""" & AttCore.htmlspecial +chars(customer,ENT_QUOTES) & _ """ masterIpaddr=""" & masterIpaddr & _ """ version=""" & AttCore.getVersion() & _ """ genDate=""" & AttCore.formatDate(,,Empty) +& _ """ timestamp=""" & AttCore.formatDate(AttCore +DateTimeUnix,,Empty) & """ >" ' document the aggrs used in this device list: Dim sAggrAddress For Each sAggrAddress In dictAggr.Keys ' WScript.Echo " aggr IP address=" & sAggrAddress oStream.Writeline " <aggr ipAddr=""" & sAggrAddress & _ """ aggrID=""" & dictAggr.Item(sAggrAddres +s) & """ />" Next Dim iTotalDevRead: iTotalDevRead = 0 ' count the monitored devic +es in inventory For Each sAggrAddress In dictAggr.Keys Dim sAggrID: sAggrID=dictAggr.Item(sAggrAddress) WScript.Echo " aggr IP address=" & sAggrAddress mssqlServer=sAggrAddress Set oCon=MssqlADODB.connect(sAggrAddress) If oCon Is Nothing Then ATTEASE.APP.getEmailSubject().addIssue "ADODB connection + open failed" ATTEASE.LOG.write(" ").WriteMsg "6110","E","ADODB conne +ction open to "& sAggrAddress & " failed for reason: " & MSsqlADODB.e +rrstr buildDeviceList=False Exit Function End If Dim sDevIPv6Sarg: sDevIPv6Sarg=AttCore.Choose(hasIPv6(),"coal +esce(b.devIPv6,'')","''") Set oRst = CreateObject("ADODB.Recordset") ' !!!!!! Note: check devIPv6 - may be wrong. check IPAddress +String for substitute for both v6 and v4 ' !!!!! check address type devAddrType Dim sSelect sSelect="select distinct " & _ "rtrim(a.devName) as devName, " & _ "coalesce(b.devipstring,'') as devipstring, " & _ sDevIPv6Sarg & " as devIPv6, " & _ "suspend = case when a.suspend = 0 then 'active' els +e 'deactivated' end," & _ "convert(varchar(20),a.devLastModified,120) as devLa +stModified, " & _ "a.devId, " & _ "b.domainId, " & _ "c.domainName, " & _ "'" & sAggrAddress & "' as aggrIpaddr, " & _ "'" & sAggrID & "' as aggrID, " & _ "'" & AttCore.getConfig().Customer & "' as account, +" & _ "c.parentDomainId " & _ "from VNAggr.dba.devtable a " & _ " inner join VNaggr.dba.resourceview b " & _ " on a.devid = b.devid " & _ " inner join vnaggr.dba.domaintable c " & _ " on b.domainId = c.domainId " ' WScript.Echo sSelect On Error Resume Next oRst.Open sSelect,oCon,adOpenForwardOnly,adLockReadOnly,adCmd +Text If Err.Number Then sErrDescr=Err.description On Error GoTo 0 Err.Clear buildDeviceList=False ATTEASE.APP.getEmailSubject().addIssue "Query for aggrs fa +iled" ATTEASE.LOG.writeMsg "6130","E", _ "ADODB Query open for device list fai +led for reason: " & sErrDescr Exit Function End If On Error GoTo 0 Dim iDevRead: iDevRead = 0 Do Until oRst.EOF iDevRead = iDevRead + 1 iTotalDevRead = iTotalDevRead + 1 If False Then WScript.Echo " devName=" & oRst("devName").Value & _ ", devIpString=" & oRst("devIpString").Value +& _ ", devIPv6=" & oRst("devIPv6").Value & _ ", suspend=" & oRst("suspend").Value & _ ", devLastModified=" & oRst("devLastModified" +).Value & _ ", devId=" & oRst("devId").Value & _ ", domainId=" & oRst("domainId").Value & _ ", domainName=" & oRst("domainName").Value & +_ ", aggrIpaddr=" & oRst("aggrIpaddr").Value & +_ ", aggrID=" & oRst("aggrID").Value & _ ", account=" & oRst("account").Value & _ ", parentDomainId=" & oRst("parentDomainId"). +Value End If ' DATETIME format 120 is ODBC canonical format: yyyy-mm-dd h +h:mm:ss oStream.Writeline " <device deviceName=""" & AttCore.htmlsp +ecialchars(oRst("devName").Value,ENT_QUOTES) & _ """ deviceIpaddr=""" & oRst("devIpString") +.Value & _ """ devIPv6=""" & oRst("devIPv6").Value & +_ """ suspend=""" & oRst("suspend").Value & +_ """ deviceLastModified=""" & oRst("devLast +Modified").Value & _ """ deviceId=""" & oRst("devId").Value & _ """ domainId=""" & oRst("domainId").Value +& _ """ domainName=""" & AttCore.htmlspecialch +ars(oRst("domainName").Value,ENT_QUOTES) & _ """ aggrIpaddr=""" & oRst("aggrIpaddr").Va +lue & _ """ aggrID=""" & oRst("aggrID").Value & _ """ account=""" & AttCore.htmlspecialchars +(oRst("account").Value,ENT_QUOTES) & _ """ parentDomainId=""" & oRst("parentDomai +nId").Value & _ """ />" oRst.MoveNext Loop oRst.Close Set oRst=Nothing oCon.Close Set oCon=Nothing ATTEASE.LOG.Write(" ").writeMsg "6140","I", _ "Devices for aggr " & sAggrAddress & +" processed: " & iDevRead Next oStream.Writeline "</vnDevList>" oStream.Close ATTEASE.LOG.Write(" ").writeMsg "6150","I", _ "Total devices processed: " & iTotalDe +vRead ATTEASE.LOG.writeline "" If AttCore.getTraceLevel() > 0 Then ATTEASE.LOG.writeMsg "6199","I","End buildDeviceList at " & At +tCore.formatDate(,,Empty) End If buildDeviceList=bReturnCode End Function ' buildDeviceList ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' End Application logic ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^ ' Namespace MssqlADODB and static factory function MssqlADODB.connect +(server) ' Application must instantiate MssqlADODB as an instance of MssqlADOD +B_ ' ' Call ADODB.Connection to create custom database connection handle f +or ' MS SQL Server. ' ' Fetch default parameters from configuration. Fetch overrides such ' as IP address from named arguments. ' ' Usage: ' ' Set oCon=MssqlADODB.connect(server) ' If oCon Is Nothing Then ' ATTEASE.LOG.writeMsg "nnnn","E", _ ' "Failed connecting to MS SQL Server databa +se at " & server & _ ' MssqlADDB.errstr ' End If ' ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^ Class MssqlADODB_ Private sErrstr Public Property Get errstr() errstr=sErrstr End Property Private Property Let errstr(ByVal s) sErrstr=s End Property Public Sub Class_Initialize errstr="" End Sub Function connect(ByVal server) On Error GoTo 0 errstr="" Set connect=Nothing Dim config: Set config=AttCore.getConfig() Dim watchlet: Set watchlet=config.watchlet Dim mssqlUserid: mssqlUserid=watchlet.mssqlUserid Dim mssqlPassword: mssqlPassword=watchlet.mssqlPassword Dim sErrDescr ' capture error message from VBScript Err object On Error Resume Next Dim oCon: Set oCon = CreateObject("ADODB.Connection") oCon.ConnectionTimeout=watchlet.mssqlConnectionTimeout ' default +is 15 seconds oCon.CommandTimeout=watchlet.mssqlCommandTimeout ' default +is 30 seconds oCon.IsolationLevel=adXactBrowse ' read unc +ommitted oCon.Mode=adModeRead oCon.Open "Driver={" & AttAdo.getMsSqlServerDriver() & "};Server= +" & server & ";Database=master;Uid=" & _ mssqlUserid & ";Pwd=" & mssqlPassword If Err.Number <> 0 Then sErrDescr=Err.Description On Error GoTo 0 errstr="Connection open failed for reason: " & sErrDescr Set connect=Nothing Exit Function End If oCon.Execute "set lock_timeout " & watchlet.mssqlLockTimeout ' de +nominated in milliseconds If Err.Number <> 0 Then sErrDescr=Err.Description oCon.Close() On Error GoTo 0 Set connect=Nothing sErrstr="set lock_timeout failed for reason: " & sErrDescr Exit Function End If On Error Goto 0 Set connect=oCon End Function ' connect End Class ' MssqlADODB_ ]]> </script> </job> </package> <!-- end vnDevList.wsf -->
adding a plus button to change perl GUI dynamically during press (Perl TK)
1 direct reply — Read more / Contribute
by Ganesh Bharadwaj1
on Aug 23, 2016 at 03:27
    Hi Monks,

    I have written the following code. In this code in the 'XY Co-Ordinates and Metal to trace' block, we are rewriting similar code over and over (4 times). I want the user to have a + button, which user can click to add a new X, Y, Metal options pane. This way, user can enter how many ever X, Y, Metal options he wants by clicking the plus button and not be restricted by the 4 X,Y options I have provided.

    But note that whatever value he types in, has to be retrieved when I press the push button. You can see that I am printing the values in the text bar based on the input values provided by the user. Is there a way to modify this code to achieve the required functionality?

    #!/usr/local/bin/perl use Tk; use Tk::widgets qw(LabFrame); use File::Spec::Functions qw(canonpath); use Tk::Optionmenu; use Scalar::Util qw(looks_like_number); use Cwd 'abs_path'; my $o_xco_ordinate; my $o_yco_ordinate; my $o_metal_layer=""; my $o_processoption = "180nm"; my $o_gdsname; my $o_mw = MainWindow->new; # File Entry and Getting File from location. my $o_file_lf = $o_mw->LabFrame( -label => 'File Name', -labelside => 'acrosstop', -foreground => 'blue', ); $o_file_lf->pack( -expand => 0, -fill => 'x', ); my $o_ent = $o_file_lf->Entry( -width => 35, )->grid( -row => 0, -column => 0, -padx => 5, -pady => 5, ); my $o_file_btn = $o_file_lf->Button( -text => 'Select', -command => sub { o_get_file() }, )->grid( -row => 0, -column => 1, -padx => 5, -pady => 5, ); #Entering the metal stack options and metal lines my $o_metaloption_lf = $o_mw->LabFrame( -label => 'XY Co-Ordinates and Metal to trace', -labelside => 'acrosstop', -foreground => 'blue', ); $o_metaloption_lf->pack( -expand => 0, -fill => 'x', ); my $o_frm_metalOption =$o_metaloption_lf ->Frame()->pack; # just for c +entering the buuton row #######################################SETTING DEFAULT################ +################################################ my $o_default_metal = "NONE"; my $o_default_x = ""; my $o_default_y = ""; ##########################################Co-ordinate and metal option +: Row 1 #################################################### #my $o_f_metal = $o_mw->Frame->pack; my $o_f_coord = $o_mw->Frame->pack; #my $o_f_coord = $o_mw->Frame->pack; $o_f_coord->Label(-text => 'X1:')-> grid(-row=>0,-column=>0)->pack(-si +de => 'left'); # Setting the default entry values. my $o_e_x = $o_f_coord->Entry(-textvariable => \(my $o_x = $o_default_ +x)) -> grid(-row=>0,-column=>1)->pack(-side => 'l +eft'); $o_f_coord->Label(-text => 'Y1:')-> grid(-row=>0,-column=>2)->pack(-si +de => 'left'); my $o_e_y = $o_f_coord->Entry(-textvariable => \(my $o_y = $o_default_ +y)) -> grid(-row=>0,-column=>3) ->pack(-side => ' +left'); my $o_o_metal = $o_f_coord->Optionmenu( -options => [[M1=>"M1"], [M2=>"M2"], [M3=>"M3"], [M4=>"M4"],[ +M5=>"M5"],[M6=>"M6"],[M7=>"M7"], [M8=>"M8"],[B1=>"B1"],[B2=>"B2"],[B3 +=>"B3"],[B4=>"B4"],[BA=>"BA"],[BB=>"BB"], [BD=>"BD"], [BE=>"BE"], [FA +=>"FA"], [FB=>"FB"], [L1=>"L1"], [L2=>"L2"], [L3 =>"L3"],[EA=>"EA"], +[EB=>"EB"], [LB=>"LB"],[NONE=>" "]], -variable => \ my $o_metal, -textvariable => \ my $o_t_metal, )-> grid(-row=>0,-column=>4) ->pack; # Set the default option. #$o_metal = $o_default_metal; $o_t_metal = $o_default_metal; ##########################################Co-ordinate and metal option +: Row 2 #################################################### my $o_f_coord2 = $o_mw->Frame->pack; #my $o_f_coord = $o_mw->Frame->pack; $o_f_coord2->Label(-text => 'X2:')-> grid(-row=>0,-column=>0)->pack(-s +ide => 'left'); # Setting the default entry values. my $o_e_x2 = $o_f_coord2->Entry(-textvariable => \(my $o_x2 = $o_defau +lt_x)) -> grid(-row=>0,-column=>1)->pack(-side => 'l +eft'); $o_f_coord2->Label(-text => 'Y2:')-> grid(-row=>0,-column=>2)->pack(-s +ide => 'left'); my $o_e_y2 = $o_f_coord2->Entry(-textvariable => \(my $o_y2 = $o_defau +lt_y)) -> grid(-row=>0,-column=>3) ->pack(-side => ' +left'); my $o_o_metal2 = $o_f_coord2->Optionmenu( -options => [[M1=>"M1"], [M2=>"M2"], [M3=>"M3"], [M4=>"M4"],[ +M5=>"M5"],[M6=>"M6"],[M7=>"M7"], [M8=>"M8"],[B1=>"B1"],[B2=>"B2"],[B3 +=>"B3"],[B4=>"B4"],[BA=>"BA"],[BB=>"BB"], [BD=>"BD"], [BE=>"BE"], [FA +=>"FA"], [FB=>"FB"], [L1=>"L1"], [L2=>"L2"], [L3 =>"L3"],[EA=>"EA"], +[EB=>"EB"], [LB=>"LB"],[NONE=>" "]], -variable => \ my $o_metal2, -textvariable => \ my $o_t_metal2, )-> grid(-row=>0,-column=>4) ->pack; # Set the default option. #$o_metal = $o_default_metal; $o_t_metal2 = $o_default_metal; ##########################################Co-ordinate and metal option +: Row 3 #################################################### my $o_f_coord3 = $o_mw->Frame->pack; #my $o_f_coord = $o_mw->Frame->pack; $o_f_coord3->Label(-text => 'X3:')-> grid(-row=>0,-column=>0)->pack(-s +ide => 'left'); # Setting the default entry values. my $o_e_x3 = $o_f_coord3->Entry(-textvariable => \(my $o_x3 = $o_defau +lt_x)) -> grid(-row=>0,-column=>1)->pack(-side => 'l +eft'); $o_f_coord3->Label(-text => 'Y3:')-> grid(-row=>0,-column=>2)->pack(-s +ide => 'left'); my $o_e_y3 = $o_f_coord3->Entry(-textvariable => \(my $o_y3 = $o_defau +lt_y)) -> grid(-row=>0,-column=>3) ->pack(-side => ' +left'); my $o_o_metal3 = $o_f_coord3->Optionmenu( -options => [[M1=>"M1"], [M2=>"M2"], [M3=>"M3"], [M4=>"M4"],[ +M5=>"M5"],[M6=>"M6"],[M7=>"M7"], [M8=>"M8"],[B1=>"B1"],[B2=>"B2"],[B3 +=>"B3"],[B4=>"B4"],[BA=>"BA"],[BB=>"BB"], [BD=>"BD"], [BE=>"BE"], [FA +=>"FA"], [FB=>"FB"], [L1=>"L1"], [L2=>"L2"], [L3 =>"L3"],[EA=>"EA"], +[EB=>"EB"], [LB=>"LB"],[NONE=>" "]], -variable => \ my $o_metal3, -textvariable => \ my $o_t_metal3, )-> grid(-row=>0,-column=>4) ->pack; # Set the default option. #$o_metal = $o_default_metal; $o_t_metal3 = $o_default_metal; ###################################################################### +############################################################ #Entering the metal stack options and metal lines ##########################################Co-ordinate and metal option +: Row 4 #################################################### my $o_f_coord4 = $o_mw->Frame->pack; #my $o_f_coord = $o_mw->Frame->pack; $o_f_coord4->Label(-text => 'X4:')-> grid(-row=>0,-column=>0)->pack(-s +ide => 'left'); # Setting the default entry values. my $o_e_x4 = $o_f_coord4->Entry(-textvariable => \(my $o_x4 = $o_defau +lt_x)) -> grid(-row=>0,-column=>1)->pack(-side => 'l +eft'); $o_f_coord4->Label(-text => 'Y4:')-> grid(-row=>0,-column=>2)->pack(-s +ide => 'left'); my $o_e_y4 = $o_f_coord4->Entry(-textvariable => \(my $o_y4 = $o_defau +lt_y)) -> grid(-row=>0,-column=>3) ->pack(-side => ' +left'); my $o_o_metal4 = $o_f_coord4->Optionmenu( -options => [[M1=>"M1"], [M2=>"M2"], [M3=>"M3"], [M4=>"M4"],[ +M5=>"M5"],[M6=>"M6"],[M7=>"M7"], [M8=>"M8"],[B1=>"B1"],[B2=>"B2"],[B3 +=>"B3"],[B4=>"B4"],[BA=>"BA"],[BB=>"BB"], [BD=>"BD"], [BE=>"BE"], [FA +=>"FA"], [FB=>"FB"], [L1=>"L1"], [L2=>"L2"], [L3 =>"L3"],[EA=>"EA"], +[EB=>"EB"], [LB=>"LB"],[NONE=>" "]], -variable => \ my $o_metal4, -textvariable => \ my $o_t_metal4, )-> grid(-row=>0,-column=>4) ->pack; # Set the default option. #$o_metal = $o_default_metal; $o_t_metal4 = $o_default_metal; ###################################################################### +############################################################ #Running the file my $o_run_lf = $o_mw->LabFrame( -label => 'Run', -labelside => 'acrosstop', -foreground => 'blue', ); $o_run_lf->pack( -expand => 1, -fill => 'both', ); my $o_but = $o_run_lf->Button( -text => "Go!", -command => \&o_push_button, )->pack; # clear my $o_but_clear = $o_run_lf->Button( -text => "Clear Text Box", -command => \&o_clearme, )->pack; #Text Box my $o_txt = $o_run_lf->Scrolled( 'Text', -width => 40, -height => 15, -wrap => 'word', -scrollbars => 'e', -background => 'white', ); $o_txt->pack( -expand => 1, -fill => 'both', -padx => 5, -pady => 5, ); MainLoop; #SUB PROCEDURES sub o_get_dir { # JFileDialog works better on Windows XP ;) #my @a_types = (["Layout files", [qw/.gds .oas .oas.gz .gds.gz/]]); my $o_dir_dlg = $o_mw->chooseDirectory(-initialdir => '~', -title => 'Choose a directory'); print "$o_dir_dlg selected as directory\n"; #return($o_file_dlg); # Use getOpenFile if that's not important # my $o_file_dlg = $o_mw->JFileDialog( # -Title => 'File name', # -Create => 0, # -Path => File::HomeDir->my_documents, # -FPat => '*.txt', # -ShowAll => 'NO' # ); # my $o_file = $o_file_dlg->Show(-Horiz => 1); my $o_dir = $o_dir_dlg; unless ($o_dir) { print "cancelled...\n"; return; } $o_dir = canonpath($o_dir); o_update_dir($o_dir); return($o_dir); } sub o_update_dir { my $o_value_dir = shift; $o_entdir->delete( 0, 'end' ); $o_entdir->insert( 0, $o_value_dir ) if defined $o_value_dir; return; } sub o_clearme { $o_txt-> delete("1.0",'end'); } sub o_push_button { if (($o_x eq "") || ($o_y eq "") || ($o_metal eq "")) { $o_metal = ""; $o_x = ""; $o_y = ""; } if (($o_x2 eq "") || ($o_y2 eq "") || ($o_metal2 eq "")) { $o_metal2 = ""; $o_x2 = ""; $o_y2 = ""; } if (($o_x3 eq "") || ($o_y3 eq "") || ($o_metal3 eq "")) { $o_metal3 = ""; $o_x3 = ""; $o_y3 = ""; } if (($o_x4 eq "") || ($o_y4 eq "") || ($o_metal4 eq "")) { $o_metal4 = ""; $o_x4 = ""; $o_y4 = ""; } if (($o_x5 eq "") || ($o_y5 eq "") || ($o_metal5 eq "")) { $o_metal5 = ""; $o_x5 = ""; $o_y5 = ""; } if (($o_x6 eq "") || ($o_y6 eq "") || ($o_metal6 eq "")) { $o_metal6 = ""; $o_x6 = ""; $o_y6 = ""; } if (($o_x7 eq "") || ($o_y7 eq "") || ($o_metal7 eq "")) { $o_metal7 = ""; $o_x7 = ""; $o_y7 = ""; } $o_txt->insert( 'end', "$o_x $o_y $o_metal\n" ); $o_txt->insert( 'end',"$o_x2 $o_y2 $o_metal2 \n"); $o_txt->insert( 'end',"$o_x3 $o_y3 $o_metal3 \n"); $o_txt->insert( 'end',"$o_x4 $o_y4 $o_metal4 \n"); $o_txt->update(); } sub o_get_file { my @o_types = (["Layout files", [qw/.gds .oas .oas.gz .gds.gz/]] ); my $o_file_dlg = $o_mw->getOpenFile(-filetypes => \@o_types) or retu +rn(); print "$o_file_dlg selected\n"; my $o_file = $o_file_dlg; unless ($o_file) { print "cancelled...\n"; return; } $o_file = canonpath($o_file); o_update_file($o_file); return($o_file); } sub o_update_file { my $o_value = shift; $o_ent->delete( 0, 'end' ); $o_ent->insert( 0, $o_value ) if defined $o_value; return; }
    thanks,
Good Perl-based web Calendar Frameworks?
1 direct reply — Read more / Contribute
by Cody Fendant
on Aug 22, 2016 at 22:31

    I'm trying to set up a calendaring system at work (various events start or finish on any given day and I need to be reminded of them) and I'd like it to be something created in Perl.

    Any recommendations for a web framework/module which has good calendar functions? Obviously, online calendar output by day, week, month etc. would be good but also email functions to say "don't forget X happens today".

reset libpath
1 direct reply — Read more / Contribute
by pdupre
on Aug 22, 2016 at 21:41
    Hello, I need to change my libpath. ldconfig -p|grep gsl libgsl.so.19 (libc6,x86-64) => /lib64/libgsl.so.19 libgsl.so (libc6,x86-64) => /lib64/libgsl.so I wish to change libgsl.so => /usr/local/mygsl/lib/libgsl.so How can I do ? thank
    Patrick Dupre Universite du Littoral, FR Dunkirk
CamelCase really that bad?
4 direct replies — Read more / Contribute
by gzartman
on Aug 22, 2016 at 21:05

    So, I started a pretty big project and decided to use CamelCase for vars and methods because some other classes I was using used it, and quite honestly I like it better. :)

    However, now I'm starting to question me decision. I'm starting to wonder if I should have followed the more traditional approach as detailed in the Camel. I'm still at a place I can convert over (with only moderate pain).

    I'm curious what you guys think? Is going with camelCase for vars and methods really that big of a deal?
Devel::Cover for myfile.pl with different command-line input arguments
2 direct replies — Read more / Contribute
by tito80
on Aug 22, 2016 at 15:08
    Hi PerlMonks,

    I am a newbie and pardon my ignorance. I am trying to use Devel::Cover (DC) to get an idea of the code coverage of my my_file.pl ran with arg1 arg2, etc. as command-line input arguments. I am using Perl 5.8.9 with 1.23 DC. The steps I executed successfully to generate the html file are:

    1) perl -MDevel::Cover my_file.pl -arg1 <arg1_value> -arg2 <arg2_value>

    2) Devel-Cover-1.23/bin/cover cover_db --report=html

    Now, I do not have packages/modules to test directly. But I have the my_file.pl file which invokes several packages.

    And I need to test my_file.pl with several different combinations of command line i/p arguments (i.e. <arg1_different_value1>, <arg2_different_value_2>, etc.). All these test combinations are a part of my regression suite (you can think of the options written in a test.txt file sequentially) and I am trying to see if Devel::Cover can assure that I have 100% code coverage with these tests.

    While I can run the above in a for-loop, each time with different arguments, I am not sure if that is the best way since I will end up with 100's of html/report files that need to be merged for any meaningful purpose.

    Could you kindly provide some pointers?

    Thanks, Tito

Leading empty array elements after splitting
3 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 22, 2016 at 11:16

    I'm attempting to extract numbers from codes in this generalised format (always begin with MD:Z: but what follows is variable):

    MD:Z:4C3C7C0T2^T9C44

    Desired output (separate array elements):

    4 3 7 0 2 9 44

    As I need to maintain positional information and length of each number (i.e. it must be clear that 44 = 44 and not the product of something like 4T4 after screening out letters) i've tried to use split:

    my @test = split((/\D/g), $input);

    To split on any non-number; however this returns a set of leading empty array values arising from the consecutive matches on 'MD:Z:'. Is there a way to suppress these or a better way to go about getting the desired result?


Add your question
Title:
Your question:
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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (12)
    As of 2016-08-24 15:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The best thing I ever won in a lottery was:















      Results (347 votes). Check out past polls.