One additional remark -- when you don't return any value from a Perl
subroutine explicitly with the 'return' statement, Perl always returns the
value of the last regular statement. So instead of "return 1;" in the
previous example, writing just "1;" would produce the same effect.
hth,
risto

2017-08-03 22:46 GMT+03:00 Risto Vaarandi <risto.vaara...@gmail.com>:

>
> 2017-08-03 16:40 GMT+03:00 Stuart Kendrick <stua...@alleninstitute.org>:
> ...
>
>>
>>
>> But this is fine – a classic challenge, which sec is prepared to meet.
>>
>>
>>
>> So, I created a global hash using SEC_STARTUP / SEC_INTERNAL_EVENT
>>
>>
>>
>> # Global variables for Isilon
>>
>> type=Single
>>
>> ptype=SubStr
>>
>> pattern=SEC_STARTUP
>>
>> context=SEC_INTERNAL_EVENT
>>
>> desc=initialize array-id to node mapping hash
>>
>> action=lcall %o-> (sub {\
>>
>>                          %array_to_node = (21 => 1,\
>>
>>                                            24 => 2,\
>>
>>                                             3 => 3,\
>>
>>                                             4 => 4,\
>>
>>                                             5 => 5,\
>>
>>                                             6 => 6,\
>>
>>                                            23 => 7,\
>>
>>                                             8 => 8,\
>>
>>                                             9 => 9,\
>>
>>                                            10 => 10,\
>>
>>                                            11 => 11,\
>>
>>                                            12 => 12,\
>>
>>                                            13 => 13,\
>>
>>                                            18 => 14,\
>>
>>                                            22 => 15,\
>>
>>                                           )\
>>
>>
>>
>>                                           )\
>>
>>                         }\
>>
>>                     )\
>>
>>
>>
>>
>>
>> Question:  What is this “%o->” syntax doing?  I don’t recognize it.
>> Reading the ‘lcall’ section in the man page … am I correct in understanding
>> that this ‘action’ is assigning the hash ‘%array_to_node’ to the hash ‘%o’?
>>
>>
>>
>>
>>
>> --sk
>>
>>
>>
>>
> hi Stuart,
> the 'lcall' action always takes at least two parameters -- an action list
> variable (%o in the above example) and a perl function (the code that
> follows the arrow). The purpose of the action list variable is to store the
> return value from the perl function, since in many cases 'lcall' is used
> for data conversions, arithmetic calculations, etc where fetching the
> result of the function is essential. In the case of your example rule,
> retrieving the return value is not important, but the %o variable is
> nevertheless set to a list of key-value pairs from the hash, since
> assignment to a hash is the last (and only) statement in the function. If
> you don't want the assignment of the entire list to take place, you can
> just return 1 (or some other scalar value) from the function, for example:
>
> type=Single
> ptype=SubStr
> pattern=SEC_STARTUP
> context=SEC_INTERNAL_EVENT
> desc=initialize array-id to node mapping hash
> action=lcall %myreturnvalue -> (sub {\
>                          %array_to_node = (21 => 1,\
>                                            24 => 2,\
>                                             3 => 3,\
>                                             4 => 4,\
>                                             5 => 5,\
>                                             6 => 6,\
>                                            23 => 7,\
>                                             8 => 8,\
>                                             9 => 9,\
>                                            10 => 10,\
>                                            11 => 11,\
>                                            12 => 12,\
>                                            13 => 13,\
>                                            18 => 14,\
>                                            22 => 15,\
>                                           );\
>                           return 1; \
>                         }\
>                     )\
>
>
> Hope this helps,
> risto
>
>
>>
>>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to