Now I have the following problem.

I need to count how many times certain traffic comes from an IP address. I'm 
using perl hashes for that where the IP address is the key and the counter is 
the value. Fine so far. Then, I need to report that and for that I'm doing the 
following inside eval:
while ( my ($key, $val) each %%my_hash) {
   print (IP: $key, counter: $val);
}

The counter values print fine but all keys print some gibberish instead of the 
IP addresses.

Any suggestions?

BTW: I'm counting the events using eval %o (++$my_hash{$3}); where $3 has the 
IP value that I need to record.

Thanks,
Rafael

On Apr 8, 2011, at 2:56 PM, Risto Vaarandi wrote:

> Rafael,
> you need to escape the %-sign with another %, so %hash should be
> written as %%hash.
> The problem is that action list variables also begin with %, and they
> are substituted before the Perl code is evaluated. With pre 2.6
> versions, variables without values were not substituted, but this
> created confusion, since in some cases variables needed escaping and
> in some cases not. Now there is a uniform treatment for all variables,
> and unset or undefined variables will be replaced with an empty
> string.
> regards,
> risto
> 
> 2011/4/8 Rafael Bonilla <rafael.boni...@gmail.com>:
>> Hi,
>> 
>> I need to create a hash_ref for some hash I created before so I'm using eval 
>> for that:
>> 
>> ...
>> action=eval %v ($hash_ref = \%my_hash; ...)
>> 
>> I'm always getting an error message because the line is recognized as 
>> "$hash_ref=\" (the hash name is missing). Do I need to escape some of the 
>> characters here (\ %)?
>> 
>> Any help will be appreciated,
>> Rafael
>> ------------------------------------------------------------------------------
>> Xperia(TM) PLAY
>> It's a major breakthrough. An authentic gaming
>> smartphone on the nation's most reliable network.
>> And it wants your games.
>> http://p.sf.net/sfu/verizon-sfdev
>> _______________________________________________
>> Simple-evcorr-users mailing list
>> Simple-evcorr-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
>> 


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to