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 thought I would use the same symbol? while (<LOG>) { if (/IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\(([0-9]+)\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) /){ my $x=$6; $srca{$2}+=$x; $foo=sprintf("%16s -> %16s %3s port %-6s",$2,$4,$1,$5); $moo=sprintf("%3s port %-6s",$1,$5); $quad{$foo}+=$x; $port{$moo}+=$x; next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \ $srca{ $2 } += $5; $quad{ sprintf '%16s -> %16s %3s port %-6s', $2, $3, $1, $4 } += $5; $port{ sprintf '%3s port %-6s', $1, $4 } += $5; } } On Mon, Sep 22, 2008 at 2:14 AM, Raymond Wan <[EMAIL PROTECTED]> wrote: > > 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 check. > > Declaring them (locally) is to do: > > my $x; > > Giving it an initial value (any value, not just "0") would be: > > $x = 123; > > You could very well do them on separate lines; what John suggested is to do > it all in one line: > > my $x = 123; > > which is of course, ok. Anyway, the point is, you need to declare them with > "my" first before you use them. With respect to your reply below, it > doesn't matter whether you gave it a value of 0 or some other value...there > is no rule on what an initial value should be...whatever fits your > situation. But, you need to declare it. > > Ray > > > Stephen Reese wrote: >>> >>> 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 >>> >>> >> >> Jeff, are they not defined here: >> >> $x=$6; >> $srca{$2}+=$x; >> $foo=sprintf("%16s -> %16s %3s port %-6s",$2,$4,$1,$5); >> $moo=sprintf("%3s port %-6s",$1,$5); >> $quad{$foo}+=$x; >> $port{$moo}+=$x; >> >> or must they be set to something like 0? >> >> Thanks >> >> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/