Thank you Risto!. Really usefull.
2016-04-27 9:38 GMT+02:00 Risto Vaarandi <risto.vaara...@gmail.com>:
> hi Jaren,
>
> your current module is not exporting any names, and therefore the
> functions and variables in the module are not accessible outside the
> module. In order to fix the problem, you have to export relevant names with
> the Exporter module. Firstly, you have to load the Exporter module with
> 'require Exporter' statement which is followed by several other statements
> declaring the module version and exporting relevant names.
>
> Couple of weeks ago, I posted a relevant example to this thread:
>
> https://sourceforge.net/p/simple-evcorr/mailman/simple-evcorr-users/?viewmonth=201604&viewday=16
>
> This example exports both a function name and a hash table name, so you
> should be able to use this example with only few modifications in your own
> environment.
>
> If you want the get more detailed information about name exporting, please
> have a look into perl standard documentation (
> http://perldoc.perl.org/Exporter.html). It is quite extensive and might
> take time to read, but all details are nevertheless covered there.
>
> There is also another caveat in your ruleset -- the following definition
>
> action=lcall %o (print Data::Dumper::Dumper($blacklist->getHash());)
>
> is not the correct one, since 'lcall' expects to get a function definition
> for its last parameter. Therefore, you should probably rewrite the
> definition as:
>
> action=lcall %o -> ( sub { print
> Data::Dumper::Dumper($blacklist->getHash()); } )
>
>
> kind regards,
> risto
>
> 2016-04-26 18:19 GMT+03:00 Jaren Peich <burkol...@gmail.com>:
>
>> Hi,
>>
>> Finally i have to load various files in different hash tables and i
>> created a class to do it and the problem is that i can“t access to the
>> objects and methods that i create on the class. SecIP class file has to be
>> in the same folder as the rules to use the objects?
>>
>> Scene:
>> Path File:C:\Sec\lib\SecIP.pm
>>
>> SecIP.pm
>> _____________________________________________________________________
>> package SecIP;
>> use strict;
>> use warnings;
>> use autodie;
>>
>> sub new {
>> my $class = shift;
>> my $path = shift;
>>
>> open my $URL, '<', $path;
>> my (@url) = <$URL>;
>> chomp(@url);
>> close $URL;
>>
>> my %list = map { $_ => 1 } @url;
>> my $self = \%list;
>>
>> bless $self, $class;
>>
>> return $self;
>> }
>>
>> sub getNumberElements {
>> my $self = shift;
>>
>> return keys %$self;
>> }
>>
>> sub existsElement{
>> my $self = shift;
>> my $element = shift;
>>
>> return exists $self->{$element};
>> }
>>
>> sub getHash {
>> my $self = shift;
>>
>> return {%{$self}};
>> }
>>
>> 1;
>>
>>
>> Path File:C:\Sec\lib\iniRules.conf
>>
>> iniRules.conf
>> _____________________________________________________________________
>>
>> type=Single
>> ptype=SubStr
>> pattern=SEC_STARTUP
>> context=SEC_INTERNAL_EVENT
>> continue=TakeNext
>> desc=Load the Dumper module and terminate if it is not found
>> action=assign %ret 0; eval %ret (require Data::Dumper;); eval %o (exit(1)
>> unless %ret)
>>
>> type=Single
>> ptype=SubStr
>> pattern=SEC_STARTUP
>> context=SEC_INTERNAL_EVENT
>> continue=TakeNext
>> desc=Load the SecIP module and terminate if it is not found
>> action=assign %ret 0; eval %ret (require 'C:\Sec\lib\SecIP.pm'); eval %o
>> (exit(1) unless %ret)
>>
>> type=Single
>> ptype=RegExp
>> pattern=^(?:SEC_STARTUP|SEC_RESTART|SEC_SOFTRESTART)$
>> context=SEC_INTERNAL_EVENT
>> continue=TakeNext
>> desc=create IP address table
>> action=lcall %o -> ( sub { our $blacklist =
>> SecIP->new('C:\Sec\lib\List.txt'); } )
>>
>>
>> Path File:C:\Sec\lib\List.txt
>>
>> List.txt
>> ___________________________________________________________________
>> google.com
>> yahoo.com
>> kernel.org
>>
>>
>> Path File:C:\Sec\rules.conf
>>
>> rules.conf
>> ________________________________________________________________
>>
>> type=Single
>> ptype=RegExp
>> pattern=^(?:SEC_STARTUP|SEC_RESTART|SEC_SOFTRESTART)$
>> context=SEC_INTERNAL_EVENT
>> desc=-
>> continue=TakeNext
>> action=lcall %o (print Data::Dumper::Dumper($blacklist->getHash());)
>>
>>
>> Launch command:
>> perl C:\sec\sec -intevents -fromstart -notail
>> -conf=C:\Sec\lib\iniLib.conf -conf=C:\Sec\rules.conf -log=Log.log
>>
>> Output:
>> Eval 'getHash());)' didn't return a code reference: syntax error at (eval
>> 5) line 1, n
>> Invalid action list ' lcall %o (print
>> Data::Dumper::Dumper($blacklist->getHash());) '
>>
>>
>> Thank you Risto. Regards.
>>
>>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users