Re: Using strict and configuration files
Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; unless ($conf = do ('/path/to/config.pl')) { die (Could not open file); } print $conf-{'var1'}, \n; - Then in a file called config.pl { var1 = one, var2 = two } - The unless part is just to check that the file was opened successfully. The do actually opens the file and assigns the hash structure to $conf. Hope this helps! Carl Hi all, I want to use: use strict; And I want to use a configuration file in a Perl script. The configuration file uses: %page1=( ); %page2=( ); This way I get errors if I run the script because the variables are not defined with my. I've tried putting in the configuration file: my %page1=( ); But this method doesn't work. I use a configuration file and I would like to put the settings only in this file without modifying the script. Is it possible? Thanks. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: I've been having this problem in various permutations throughout my Perl life. For this particular function, I set $confirm_counter to 1. Then I use $xheader = X-HTTP-Client: [$1]\n . X-Generated-By: NMS FormMail.pl v$VERSION\n; } if ( $confirm_counter = 1){ ^ May be this your problem? if ( $send_confirmation_mail ) { open_sendmail_pipe(\*CMAIL, $mailprog); In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } Well that may be a typo, but if you pasted this part of the script then it may be the error. tip_if_newbie If this is the error, it should be good for you to use the '-w' flag in the perl command line to check for simple errors like this. Also using: 'use strict;' could be useful. :) Just put: #!/usr/bin/perl -w use strict; At the beginning of your scripts. /tip_if_newbie See you Roberto Ruiz -- A train stops at a train station; a bus stops at a bus station; on my desk I have a workstation... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
Camilo Gonzalez wrote at Tue, 28 May 2002 19:45:53 +0200: Gurus, I've been having this problem in various permutations throughout my Perl life. For this particular function, I set $confirm_counter to 1. Then I use a foreach loop to send email to multiple recipients. Within the foreach loop, I increment $confirm_counter by using $confirm_counter++. I then use the value of $confirm_counter as a test for an if conditional. If the counter is one, then a confirmation email will be sent to the person who submitted the form. If not, the confirmation email will be skipped. This is to prevent any user from receiving more than one confirmation email. However, it seems that $confirm_counter is not being incremented and the user will receive as many as 7 email confirmations. Any ideas? I'm enclosing the code in question below. if ( $confirm_counter = 1){ ^^^ That's the problem. You wanted a comparison, but you did an assignment. Just use ==. if ( $send_confirmation_mail ) { open_sendmail_pipe(\*CMAIL, $mailprog); print CMAIL $xheader, To: $email$realname\n$confirmation_text$confirm_counter; close CMAIL; } } ++$confirm_counter; ... When the problem occurs often, there's a trick to avoid: if ( 1 == $confirm_counter ) { ... } When you write a '=' instead of '==' the interpreter is complaining before the script starts :-) Greetings, Janek PS: I'd bet, it's the most done beginner's mistake. Is there anybody who has already written a program to dedect it ? (Like lint) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
On Wed, May 29, 2002 at 03:05:36AM -0500, Roberto Ruiz ([EMAIL PROTECTED]) said something similar to: Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: if ( $confirm_counter = 1){ ^ May be this your problem? In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } You don't need the quotes if you are doing a numeric check. if($confirm_counter == 1) { ... } Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs. --Larry Wall in [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Counter and scoping(?) issue
Gack, you Perl Lords once again save my butt. Thanks Roberto, it worked like a charm. -Original Message- From: Kevin Meltzer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 7:30 AM To: Roberto Ruiz Cc: Camilo Gonzalez; [EMAIL PROTECTED] Subject: Re: Counter and scoping(?) issue On Wed, May 29, 2002 at 03:05:36AM -0500, Roberto Ruiz ([EMAIL PROTECTED]) said something similar to: Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: if ( $confirm_counter = 1){ ^ May be this your problem? In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } You don't need the quotes if you are doing a numeric check. if($confirm_counter == 1) { ... } Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs. --Larry Wall in [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Verifying the CONTENT_LENGTH
--- Octavian Rasnita [EMAIL PROTECTED] wrote: Note: I've tried using the functions for uploading from CGI module, but with no good results in Windows 2000, and that's why I want to write my code. Teddy, Can you be more specific about the no good results? If there is a problem with CGI.pm and Windows 2000, I am sure that *many* people would want to know. Cheers, Curtis Ovid Poe = Ovid on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
why do I get the following warning for taint
When I run perl -c myscript.cgi to test the syntax or perl -w ..., it produces this: Too late for -T option at maintenance.cgi line 1 (my line 1 is just the shebang line with the -T option). Does this mean that something is wrong? -Rob Carl Franks [EMAIL PROTECTED] wrote: Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; unless ($conf = do ('/path/to/config.pl')) { die (Could not open file); } print $conf-{'var1'}, \n; - Then in a file called config.pl { var1 = one, var2 = two } - The unless part is just to check that the file was opened successfully. The do actually opens the file and assigns the hash structure to $conf. Hope this helps! Carl Hi all, I want to use: use strict; And I want to use a configuration file in a Perl script. The configuration file uses: %page1=( ); %page2=( ); This way I get errors if I run the script because the variables are not defined with my. I've tried putting in the configuration file: my %page1=( ); But this method doesn't work. I use a configuration file and I would like to put the settings only in this file without modifying the script. Is it possible? Thanks. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup
Re: why do I get the following warning for taint
You need to have -T on the command line as well: perl -cT script To find out why, 'perldoc perlsec' Cheers, Kevin On Wed, May 29, 2002 at 10:51:45AM -0700, Rob Roudebush ([EMAIL PROTECTED]) said something similar to: When I run perl -c myscript.cgi to test the syntax or perl -w ..., it produces this: Too late for -T option at maintenance.cgi line 1 (my line 1 is just the shebang line with the -T option). Does this mean that something is wrong? -Rob Carl Franks [EMAIL PROTECTED] wrote: Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Politics is the entertainment branch of industry. -- Frank Zappa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cisco log parsing
Hello people i been working on this script provided by drieux but i still have some doubts about it. http://www.wetware.com/drieux/pbl/Sys/Admin/CiscoParser1.txt the scripts works fine with a small log but when i try to run it in the long log file it displays all the log file just as if it is being opened with cat. I am trying to get just the number,setup time and disconnect time from the log,,just this values in a single line like this 53353454545 18:10 18:20 When i ran the script it joins the values in a couple of lines,the problem is that i don't entirely understand the regexp,and therefore i cant break it down to get only the number,setup time and disconnect time values From the script my $dtgT = '\d|:|\.'; #numbers or colons or dots my $upT = 'SetupTime'; my $downT = 'DisconnectTime'; my $prefT = '38\#'; my $find = qr/(.*)\s+ (\d+\.\d+\.\d+\.\d+)\s* $prefT (\d+), \s* $upT\s* ([$dtgT]+)\s*$downT\s* ([$dtgT]+)/xo; so the question is how should i form the regexp to just get the number from the entire log file? how should i form the regexp get only the disconnect time? Log File: May 10 14:25:00 13310: %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 1, ConnectionId 0 0 0 0, SetupTim e 17:30:58.645 UTC Fri May 10 2002, PeerAddress 38#533147631, PeerSubAddress , DisconnectCause 2F , Disconnect Text no resource., ConnectTime 17:30:58.655 UTC Fri May 10 2002, DisconnectTime 17:30:58.655 UTC Fri May 10 200 2, CallOrigin 1, ChargedUnits 0, InfoType 2, TransmitPackets 0, TransmitBytes 0, ReceivePackets 0, ReceiveBytes 0 May 10 15:03:05 13311: %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 1, ConnectionId 0 0 0 0, SetupTim e 18:09:04.262 UTC Fri May 10 2002, PeerAddress 38#5347631, PeerSubAddress , DisconnectCause 2F , DisconnectTe xt no resource., ConnectTime 18:09:04.262 UTC Fri May 10 2002, DisconnectTime 18:09:04.262 UTC Fri May 10 2002, CallOrigin 1, ChargedUnits 0, InfoType 2, TransmitPackets 0, TransmitBytes 0, ReceivePackets 0, ReceiveBytes 0 May 10 15:03:38 %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 2, ConnectionId DF125DE2 637711D6 BD90A185 393856AE, SetupTime 18:09:15.110 UTC Fri May 10 2002, PeerAddress , PeerSubAddress , DisconnectCause 10 , DisconnectText normal call clearing., ConnectTime 18:09:37.970 UTC Fri May 10 2002, DisconnectTime 18:09: 37.970 UTC Fri May 10 2002, CallOrigin 2, ChargedUnits 0, InfoType 2, TransmitPackets 451, TransmitBytes 18040, ReceivePackets 0, ReceiveBytes 0 Thanks in advance Hernan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]