![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Run shell program in perl | s123.radha | Shell Programming and Scripting | 5 | 04-21-2008 06:39 AM |
| perl program question | hankooknara | Shell Programming and Scripting | 4 | 07-05-2007 08:01 AM |
| Invoke perl program from Ksh | mahalakshmi | Shell Programming and Scripting | 10 | 12-19-2006 04:46 AM |
| runnig a perl program from a different dir.. | sekar sundaram | Shell Programming and Scripting | 3 | 11-13-2005 01:05 AM |
| My crap PERL program | WIntellect | Shell Programming and Scripting | 9 | 10-29-2002 02:56 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
StackedHash Perl program help
Hi guys,
I need a favor from you guys. I am working on perl script which uses StackedHash( Thanks to Riccardo Murri) perl module and am almost there but unable to get it done. I really appriciate your help on this. Here are the details. thanks Purna Requirement: ========== Find out setting session state connection statements which don't have corresponding Returning WS connections in a given input file check_test_3_1.pl ============== #!/usr/bin/perl -n use Data::StackedHash; tie %array1, Data::StackedHash; if (m/(.*) \[DEBUG\] \[([^][]+)\] RMSConnectionFactory - Setting session/) { tied(%array1)->push({$2=>$_}); next; } if (m/(.*) \[DEBUG\] \[([^][]+)\] RMSConnectionFactory - Returning WS /) { if ("$2" ne "" ) { delete $array1{$2}; } next; } END { print values %array1; } Input file: ====== 2008-06-05 03:29:37,752 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:37,761 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,061 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,069 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,292 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,301 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,442 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,506 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,572 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,579 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,762 [DEBUG] [AQUEDUCT-WebContainer : 2] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,768 [DEBUG] [AQUEDUCT-WebContainer : 2] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:38,961 [DEBUG] [AQUEDUCT-WebContainer : 0] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:38,969 [DEBUG] [AQUEDUCT-WebContainer : 0] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:39,292 [DEBUG] [AQUEDUCT-WebContainer : 2] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:39,772 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:39,839 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:40,261 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:40,272 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:40,701 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:41,291 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:41,300 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection. 2008-06-05 03:29:41,542 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:41,551 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Returning WS connection. Expected Output: ============= 2008-06-05 03:29:40,701 [DEBUG] [AQUEDUCT-WebContainer : 1] RMSConnectionFactory - Setting session state for connection. 2008-06-05 03:29:39,292 [DEBUG] [AQUEDUCT-WebContainer : 2] RMSConnectionFactory - Setting session state for connection What i am getting right now: ===================== Nothing :-( program runs successfully but with no output .. Run command: ============ perl -w check_test_3_1.pl input.txt Dependency Perl Modules: =================== Data::StackedHash - Stack of PERL Hashes - search.cpan.org |
| Forum Sponsor | ||
|
|
|
|||
|
turn on warnings;
use warnings; I am not on a computer that has perl installed so I can't test your code for basic correctness, so first make sure no warnings are getting generated that might alert you to problems with the code or the code logic. |
|
|||
|
Problem is resolved
Hi
The first two lines (using StackedHash perl module0 should be there in BEGIN {} block which prevents initializing the array every pass. Problem is resolved. thanks for looking at my post. |
|||
| Google The UNIX and Linux Forums |