Re: Trying to modify Perl script

2008-09-24 Thread John W. Krahn
Stephen Reese wrote: printf() (as seen three lines down) has a format string and a list of values corresponding to the % escapes in that string. Because you are using a string literal you should use print() instead. foreach my $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { if ($n++ >= $

RE: Trying to modify Perl script

2008-09-24 Thread Stephen Reese
> printf() (as seen three lines down) has a format string and a list of > values corresponding to the % escapes in that string. Because you are > using a string literal you should use print() instead. > > > foreach my $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { > >if ($n++ >= $ntop) {

Re: Trying to modify Perl script

2008-09-23 Thread John W. Krahn
Stephen Reese wrote: In your original post you presented *two* *separate* scripts and I commented on both scripts, and now you are combining parts of both scripts which is why you seem to be confused. Hint: The "next unless //;" was a replacement for the "if (//) {}" block. John, originally I

Re: Trying to modify Perl script

2008-09-23 Thread Darren Nay
Thank you! On 9/23/08 3:10 PM, "John W. Krahn" <[EMAIL PROTECTED]> wrote: Stephen Reese wrote: > [snip] >> #next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) >> ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \; >> > next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+

RE: Trying to modify Perl script

2008-09-23 Thread Stephen Reese
> In your original post you presented *two* *separate* scripts and I > commented on both scripts, and now you are combining parts of both > scripts which is why you seem to be confused. > > Hint: The "next unless //;" was a replacement for the "if (//) {}" > block. John, originally I was trying t

Re: Trying to modify Perl script

2008-09-23 Thread John W. Krahn
Stephen Reese wrote: [snip] #next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \; next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\ ([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) /; Thanks Ron that worked. What

RE: Trying to modify Perl script

2008-09-23 Thread Stephen Reese
[snip] > > #next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) > ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \; > next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\ ([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) /; Thanks Ron that worked. What is the 'next' stat

Re: Trying to modify Perl script

2008-09-23 Thread Ron Bergin
On Sep 22, 10:16 am, [EMAIL PROTECTED] (Stephen Reese) wrote: > John, > > I made many of the changes but what is the addition of the 'next' statement > for? I tried to add the additional code but the script dies mentioning that > it is not terminated correctly. If I comment out the next statement t

RE: Trying to modify Perl script

2008-09-22 Thread Stephen Reese
John, I made many of the changes but what is the addition of the 'next' statement for? I tried to add the additional code but the script dies mentioning that it is not terminated correctly. If I comment out the next statement the script runs fine. #!/usr/bin/perl # use warnings; use strict; # S

Re: Trying to modify Perl script

2008-09-22 Thread Jeff Pang
2008/9/22 Stephen Reese <[EMAIL PROTECTED]>: > > next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) > ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \ > You didn't terminated this match statement. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMA

Re: Trying to modify Perl script

2008-09-22 Thread Stephen Reese
Okay I declared them with: my ( %srca, %quad, %port, $foo, $moo ); The last error is "Search pattern not terminated at ./acl-parse.pl line 28" or with the section of code below specifically the next statement. I googled for the error and it seems like the '\' may need to escape it but to escape I

Re: Trying to modify Perl script

2008-09-21 Thread Raymond Wan
Hi Stephen, John is saying that you need to declare them, not initializing them. Declaring them means that you're saying that variable will be used; initializing them means giving them a value. With "use strict", you need to define them before you give them a value...which is a good sanity

Re: Trying to modify Perl script

2008-09-21 Thread Jeff Pang
2008/9/22 Stephen Reese <[EMAIL PROTECTED]>: >> John is right. >> You should always 'use strict' at the begin of the scripts. >> Here you didn't declare the variables, so you got the errors. >> You could declare them with: >> my $x = ...; >> my $foo = ...; >> >> For Perl's variable scope, see this:

Re: Trying to modify Perl script

2008-09-21 Thread Stephen Reese
> John is right. > You should always 'use strict' at the begin of the scripts. > Here you didn't declare the variables, so you got the errors. > You could declare them with: > my $x = ...; > my $foo = ...; > > For Perl's variable scope, see this: > http://perl.plover.com/FAQs/Namespaces.html > Jef

Re: Trying to modify Perl script

2008-09-21 Thread Jeff Pang
2008/9/22 Stephen Reese <[EMAIL PROTECTED]>: > > $ ./acl-parse.pl > Global symbol "$x" requires explicit package name at ./acl-parse.pl > line 22. > Global symbol "$foo" requires explicit package name at ./acl-parse.pl > line 23. John is right. You should always 'use strict' at the begin of the

Re: Trying to modify Perl script

2008-09-21 Thread Stephen Reese
John, Thank you and everyone else for the insight to better Perl coding practices in the original script. I have attempted to make the changes that you recommended with negative results. I had a tough time trying to determine what to leave in so before I move on to the new script I would like to f

Re: Trying to modify Perl script

2008-09-21 Thread Dr.Ruud
"John W. Krahn" schreef: > Stephen Reese: >> chomp ($acl=$ARGV[0]); >> if ($acl eq "") { $acl=".*"}; > > my $acl = $ARGV[ 0 ] || '.*'; The chomp() can make a difference: $ perl -wle 'my $x = $ARGV[0] || q{.*}; print qq{<$x>}' '' <.*> $ perl -wle 'my $x = $ARGV[0] || q{.*}; print qq{<$x>}' ' '

Re: Trying to modify Perl script

2008-09-20 Thread John W. Krahn
Stephen Reese wrote: I found a Perl script that parses Cisco ACL logging format and I would like to modify it to parse the IPS format that Cisco uses. I have made changes to the expression that picks up the Rule and the script still runs but there isn't any useful output. Any recommendations woul

Trying to modify Perl script

2008-09-20 Thread Stephen Reese
I found a Perl script that parses Cisco ACL logging format and I would like to modify it to parse the IPS format that Cisco uses. I have made changes to the expression that picks up the Rule and the script still runs but there isn't any useful output. Any recommendations would be great. Here's wha