PERL Debugging
Hello List, I am debugging PERL code on NT. The script forks a child, and both parent and child do something. While debugging The debugger randomly toggles between the two processes. The problem Is when the child process ends, I am asked to quit the child session of the debugger. At times I am lucky in quitting the debug session under which the child was running. But sometimes, the parent session gets killed. Is there a way out. Thanks for looking into this. Ashish Tiwari ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re:clearing a variable/array
undef $variable; @array = (); Ashish Reply Separator Subject:clearing a variable/array Author: Jose Guevarra [EMAIL PROTECTED] Date: 2/28/02 8:52 AM HI, How can you clear the value of a variable or array? $variable = ; ? @array = ? or is there a special function that does this. thanx ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Received: from listserv.ActiveState.com ([209.17.183.249]) by mailserver.mail1.com with SMTP (IMA Internet Exchange 3.11) id 000C1F3A; Thu, 28 Feb 2002 09:10:08 -0800 Received: (qmail 6000 invoked from network); 28 Feb 2002 17:07:30 - Received: from localhost (HELO shot.ActiveState.com) (127.0.0.1) by localhost with SMTP; 28 Feb 2002 17:07:30 - Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 4990 invoked from network); 28 Feb 2002 17:06:33 - Received: from espresso.activestate.com (HELO smtp1.ActiveState.com) (192.168.2.150) by listserv1.activestate.com with SMTP; 28 Feb 2002 17:06:33 - Received: from correo.iquest.ucsb.edu (correo.iquest.ucsb.edu [128.111.15.4]) by smtp1.ActiveState.com (8.11.6/8.11.6) with ESMTP id g1SH6Qv14560 for [EMAIL PROTECTED]; Thu, 28 Feb 2002 09:06:26 -0800 Received: from chirpyboy (chirpy-boy.iquest.ucsb.edu [128.111.15.128]) by correo.iquest.ucsb.edu (8.11.6/8.11.6) with SMTP id g1SGtwd20397 for [EMAIL PROTECTED]; Thu, 28 Feb 2002 08:55:58 -0800 From: Jose Guevarra [EMAIL PROTECTED] To: Perl-Win32-Users [EMAIL PROTECTED] Subject: clearing a variable/array Message-ID: [EMAIL PROTECTED] MIME-Version: 1.0 Content-Type: text/plain; Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600. Importance: Normal X-PerlMx-Spam: Gauge=, Probability=0%, Report= X-Filtered-By: PerlMx makes it fast and easy. See http://www.ActiveState.com/Products/PerlMx/Header Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] X-BeenThere: [EMAIL PROTECTED] X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: mailto:[EMAIL PROTECTED]?subject=help List-Post: mailto:[EMAIL PROTECTED] List-Subscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=subscribe List-Id: Discussions relating to ActivePerl on Win32 platforms perl-win32-users.listserv.ActiveState.com List-Unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=unsubscrib e List-Archive: http://mailarchive.activestate.com/browse/perl-win32-users/ Date: Thu, 28 Feb 2002 08:52:10 -0800 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re:Does Perl have Case Statements?
This is what you can use. SWITCH: for ($start) { #start could be a, b, c, d (/^a/)do { $check = 1; last SWITCH; }; (/^b/)do { last SWITCH; }; (/^c/)do { last SWITCH; }; (/^d/)do { last SWITCH; }; (/^e/)do { last SWITCH; }; # default # do soemething else $check = 1; } Thanks, Ashish Tiwari Integrated Decisions Systems _ ___Reply Separator Subject:Does Perl have Case Statements? Author: Chris [EMAIL PROTECTED] Date: 2/28/02 3:41 PM I have been looking in the Learning Perl book, and cannot find it. I am sure that it is just a terminology thing. In VB {Yeah the old VB again :P) I could do: Select Case $Junk Case 1 Do Something Case 2 Do Something Case 3 Do Something Case 4 Do Something End Select Does Perl have something similar to where I do not have to have one humongous IF statement? I have a file I have to read in, and there are 2 fields I have to look at. In those two fields, one is a password, and I have to display the decrypted password to the admin. Reading the file is not hard. Getting the proper fields is not hard. But the password is based on something a little different so it isn't just pass the decrypt to it... I have the workaround I was given to determine it, but that means that I have to read it and look for the matching string. Thus a Case Statement, IMHO, would be the best possible solution - with my current knowledge... :) TIA!! Chris ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Received: from listserv.ActiveState.com ([209.17.183.249]) by mailserver.mail1.com with SMTP (IMA Internet Exchange 3.11) id 000C2584; Thu, 28 Feb 2002 13:47:55 -0800 Received: (qmail 11261 invoked from network); 28 Feb 2002 21:47:16 - Received: from localhost (HELO shot.ActiveState.com) (127.0.0.1) by localhost with SMTP; 28 Feb 2002 21:47:16 - Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 10797 invoked from network); 28 Feb 2002 21:46:07 - Received: from espresso.activestate.com (HELO smtp1.ActiveState.com) (192.168.2.150) by listserv1.activestate.com with SMTP; 28 Feb 2002 21:46:07 - Received: from chrisa (cs666837-200.austin.rr.com [66.68.37.200]) by smtp1.ActiveState.com (8.11.6/8.11.6) with ESMTP id g1SLk0v08783 for [EMAIL PROTECTED]; Thu, 28 Feb 2002 13:46:00 -0800 Received: from [207.115.54.47] by chrisa (ArGoSoft Mail Server Pro, Version 1.70 (1.7.0.4)); Thu, 28 Feb 2002 15:45:47 -0600 Message-ID: [EMAIL PROTECTED] From: Chris [EMAIL PROTECTED] User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.7+) Gecko/20020120 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: perl.beginners To: Win32 Perl Users [EMAIL PROTECTED] Subject: Does Perl have Case Statements? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-PerlMx-Spam: Gauge=I, Probability=1%, Report=SUBJ_ENDS_IN_Q_MARK X-Filtered-By: PerlMx makes it fast and easy. See http://www.ActiveState.com/Products/PerlMx/Header Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] X-BeenThere: [EMAIL PROTECTED] X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: mailto:[EMAIL PROTECTED]?subject=help List-Post: mailto:[EMAIL PROTECTED] List-Subscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=subscribe List-Id: Discussions relating to ActivePerl on Win32 platforms perl-win32-users.listserv.ActiveState.com List-Unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=unsubscrib e List-Archive: http://mailarchive.activestate.com/browse/perl-win32-users/ Date: Thu, 28 Feb 2002 15:41:58 -0600 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re:Sharing Variables
Remove the my from env.pl. It will work Ashish Tiwari Integrated Decisions and Systems Reply Separator Subject:Sharing Variables Author: [EMAIL PROTECTED] Date: 2/8/02 10:45 AM Question: How can I share variables between Perl scripts...? Environment: Windows NT Supporting Information: In the Unix world I've been able to accomplish this by using the 'our' variable declaration and then adding a 'require' line to other scripts along with a 'use vars' line. But in the Win32 world 'our' doesn't seem to be available and the 'my' variable declaration isn't doing the trick. I can't even get one file to see the variables in another... File Name: env.pl my $shared_var1=Hello; my $shared_var2=There; File Name: script1.pl use strict require env.pl; use vars qw($shared_var1 $shared_var2); print \$shared_var1='$shared_var1'\n; print \$shared_var2='$shared_var2'\n; Any bones you could through my way would be greatly appreciated... Regards, Dave DeLine 8140 Ward Parkway Cube 4E003 Mailstop: MOKCMP0405 913.624.6810 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Received: from listserv.ActiveState.com ([209.17.183.249]) by mailserver.mail1.com with SMTP (IMA Internet Exchange 3.11) id 0009FCD1; Fri, 8 Feb 2002 08:47:26 -0800 Received: (qmail 27135 invoked from network); 8 Feb 2002 16:46:11 - Received: from localhost (HELO shot.ActiveState.com) (127.0.0.1) by localhost with SMTP; 8 Feb 2002 16:46:11 - Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 26765 invoked from network); 8 Feb 2002 16:45:55 - Received: from espresso.activestate.com (HELO smtp1.ActiveState.com) (192.168.2.150) by listserv1.activestate.com with SMTP; 8 Feb 2002 16:45:55 - Received: from kcmgwp01.corp.sprint.com (parker1.sprint.com [208.18.122.165]) by smtp1.ActiveState.com (8.11.6/8.11.6) with ESMTP id g18Gjrk20152 for [EMAIL PROTECTED]; Fri, 8 Feb 2002 08:45:53 -0800 Received: from damgwp02.corp.sprint.com (damgwp02 [10.184.140.69]) by kcmgwp01.corp.sprint.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id g18Gl7J12128 for [EMAIL PROTECTED]; Fri, 8 Feb 2002 10:47:07 -0600 (CST) Received: from kcopmp06.corp.sprint.com (DAMGWP02.corp.sprint.com [10.184.140.69]) by damgwp02.corp.sprint.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id g18GjpB10479 for [EMAIL PROTECTED]; Fri, 8 Feb 2002 10:45:51 -0600 (CST) Received: from localhost (root@localhost) by kcopmp06.corp.sprint.com (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id KAA12615 for [EMAIL PROTECTED]; Fri, 8 Feb 2002 10:45:49 -0600 (CST) From: [EMAIL PROTECTED] X-OpenMail-Hops: 1 Message-Id: Hc1410204238.1013186748.kcopmp06@MHS Subject: Sharing Variables MIME-Version: 1.0 TO: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline; filename=BDY.RTF Content-Transfer-Encoding: 8bit X-PerlMx-Spam: Gauge=XII, Probability=16%, Report=NO_REAL_NAME X-Filtered-By: PerlMx makes it fast and easy. See http://www.ActiveState.com/Products/PerlMx/Header Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] X-BeenThere: [EMAIL PROTECTED] X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: mailto:[EMAIL PROTECTED]?subject=help List-Post: mailto:[EMAIL PROTECTED] List-Subscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=subscribe List-Id: Discussions relating to ActivePerl on Win32 platforms perl-win32-users.listserv.ActiveState.com List-Unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users, mailto:[EMAIL PROTECTED]?subject=unsubscrib e List-Archive: http://mailarchive.activestate.com/browse/perl-win32-users/ Date: Fri, 8 Feb 2002 10:45:48 -0600 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Win32::Process::Create
I have a script which runs several programs depending upon the contents of a state table ( implemented as a hash). The main script and the spawned processes write into the state table and also read from it before they perform something. Is it necessary to implement the state table as a Shared Memory and use locking of the shared memory to avoid simultaneous access by two competing processes ? I think that Shared memory is not really required as the main script and the processes it creates run in the same thread and so look at the same state table which is not possible if using fork on UNIX. On UNIX the forked child gets a copy of the variables from the parent and if both need to look at something in common ( as the state table mentioned above), the common variable needs to be implemented as shared memory. The only problem I can think of on NT is, if the processes try to access the state table simultaneously and there is a deadlock. I have tried to use Amine's MemMap module and used it's shared memory implementation on NT. It works fine and I can use the lock and unlock methods of the module to prevent simultaneous access of the shared region by two or more processes. But I need some opinion on whether such usage is an overkill, or there is another elegant way to implement it. Any views or advise is appreciated. Thanks Ashish Tiwari Integrated Decisions and Systems. [EMAIL PROTECTED] The views expressed here are mine and do not reflect the official position of my employer or the organization through which the Internet was accessed. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Need Help: Shared Memory
Hello everybody, I have a Perl script in Unix which monitors the health of a server. and also runs some other jobs in a infinite loop. It forks children to monitor the health, and run other jobs. To maintain the state it uses a hash mapped to shared memory so that the main script which is the parent and all its children can look at the hash to check the status of the system, before they perform their activities. In event of a failure of either the parent or any of it's children, the script terminates all the running children and ends - a graceful exits happens and all the zombie processes are removed. In fact the removal of zombies is performed routinely in the script through a signal handler. I have to port the same script on NT. And obviously I have to make a lot of changes: 1. Signal handling is not supported on NT. 2. The shared memory functions of Perl used in UNIX are not implememnted in Perl on NT. 3. Is it a good idea to use fork as the books (Dave Roth's Win32 Perl scripting) talk of fork not being reliable. Or is there another way to create child processes and monitor their exit codes, terminate them in case of faults and reap the zombies. Pls. Note: I am using Perl 5.6 I aslo read about using Amine's MemMap module and saw a few references to it in questions asked in this forum. I am unable to get the Module from the website as the the zip is missing. Can anyone advise me with an alternative or provide me with some hints. Thanks, Ashish Tiwari Integrated Decisions and Systems. e-mail: [EMAIL PROTECTED] ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re:Fork and multiple processes in ActivePerl for Win32
In order to create 2 children you have to fork twice. When you use fork() it returns twice. - $pid = fork(); if ($pid 0) { ### parent here ### execute parent code { elsif (defined $pid) { ### Child here ### execute child code. exit(); # end of child process. } -- Ashish Tiwari The views expressed here are mine and do not reflect the official position of my employer or the organization through which the Internet was accessed. Reply Separator Subject:Fork and multiple processes in ActivePerl for Win32 Author: DK [EMAIL PROTECTED] Date: 1/16/02 9:41 PM I am trying to write a program in ActivePerl for win32, needing to fork my code into three processes. I am trying the code below, but I only get one child (2 processes counting the parent). ** defined ($pid1=fork())||die fork failed $!; if ($pid10) {#Parent Here. defined($pid2=fork())||die fork failed $!; } #Code to be executed by both parent and children here. ** Then, I wish for the child processes to end, leaving only the parent. Since in my program I cannot create a second child (3 processes in all), I use the following code to terminate the child. ** #Code to be executed by both parent and children here. unless($pid1){ #Parent here. exit; } if($pid10){ #Parent here. waitpid($pid1,0); } #Code that only the Parent (Child is dead) executes from now on. ** How can I get 3 fully working processes? (1 Parent 2 Children) ?? And even if that is done, then how can I terminate the second child as well ? Thanks in advance. !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTMLHEAD META http-equiv=Content-Type content=text/html; charset=iso-8859-7 META content=MSHTML 6.00.2712.300 name=GENERATOR STYLE/STYLE /HEAD BODY bgColor=#ff DIVI am trying to write a program in ActivePerl for win32, needing to fork my code into three processes. BRI am trying the code below, but I only get one child (2 processes counting the parent).BR**BRdefined ($pid1=fork())||die fork failed $!;BRif ($pid1gt;0) {#Parent Here.BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp ;defined($pid2=fork())||die fork failed $!;BRBRnbsp;nbsp;}BRBR#Code to be executed by both parent and children here.BR**BRThen, I wish for the child processes to end, leaving only the parent. Since in my program I cannot create BRa second child (3 processes in all), I use the following code to terminate the child.BRBR**BR#Code to be executed by both parent and children here.BRBRunless($pid1){ nbsp;#Parent here.BRnbsp;nbsp;nbsp;nbsp;exit; nbsp;nbsp;nbsp;nbsp;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbs p;nbsp;nbsp;nbsp;nbsp;nbsp;} nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;n bsp;nbsp;nbsp;BRif($pid1gt;0){ nbsp;#Parent here.BRnbsp;nbsp;nbsp;nbsp;waitpid($pid1,0);BRnbsp;nbsp;nbsp;nbsp;} BR#Code that only the Parent (Child is dead) executes from now on.BR**BRBRHow can I get 3 fully working processes? (1 Parent 2 Children) ?? And even if that is done, then how BRcan I terminate the second child as well ?BRBRThanks in advance. /DIV/BODY/HTML Received: from listserv.ActiveState.com ([209.17.183.249]) by mailserver.mail1.com with SMTP (IMA Internet Exchange 3.11) id 000703F1; Wed, 16 Jan 2002 11:41:13 -0800 Received: (qmail 15049 invoked from network); 16 Jan 2002 19:41:08 - Received: from localhost (HELO shot.ActiveState.com) (127.0.0.1) by localhost with SMTP; 16 Jan 2002 19:41:08 - Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 14755 invoked from network); 16 Jan 2002 19:40:24 - Received: from espresso.activestate.com (HELO smtp1.ActiveState.com) (192.168.2.150) by listserv1.activestate.com with SMTP; 16 Jan 2002 19:40:24 - Received: from smtp015.mail.yahoo.com (smtp015.mail.yahoo.com [216.136.173.59]) by smtp1.ActiveState.com (8.11.6/8.11.6) with SMTP id g0GJeM730030 for [EMAIL PROTECTED]; Wed, 16 Jan 2002 11:40:22 -0800 Received: from thesi36-a098.otenet.gr (HELO ZAEBOS) (212.205.250.98) by smtp.mail.vip.sc5.yahoo.com with SMTP; 16 Jan 2002 19:40:21 - Message-ID: 002201c19ec5$c37e6130$62facdd4@ZAEBOS From: DK [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Fork and multiple processes in ActivePerl for Win32 MIME-Version: 1.0 Content-Type: multipart/alternative; X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600. X-Spam-Probability: 20% X-Spam-Mask: XX X-Filtered-By: PerlMx makes it fast and easy. See http://www.ActiveState.com/Products/PerlMx/Header Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] X-BeenThere: [EMAIL PROTECTED] X-Mailman-Version: 2.0.5 Precedence
HELP: MemMap module
Hello All: I wanted to get the MemMap module to implement shared memory in my Perl script on NT. I am unable to get it from amine's website as the Zip is not present. Does anybody have the MemMap module or has any clues. Thanks in advance. Ashish Tiwari ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users