in reply to Re^3: Performance problems on splitting long strings
in thread Performance problems on splitting long strings
... I think I first did something like:
regex1 => $regex1->(),
which gave compile errors.
You may know this already, but $regex1->() is a function invocation. The { ... } anonymous hash reference constructor tries to treat the first item returned by this function call as a value to be paired with, in this case, the key 'regex1'. If the number of items in the list consisting in the grand total of all such keys and invocations is odd, the constructor will fail with an "Odd number of elements in anonymous hash ..." error. If it is even, the hash constructed will be a meaningless mish-mosh unless the referenced functions are designed to return valid hash elements, which in this case they are not.
The expression sub {$regex1->()} produces a single code reference, which pairs as a value quite happily with any key string. It is redundant in that it simply wraps the invocation of another code reference, but this point has already been covered.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Performance problems on splitting long strings
by Laurent_R (Canon) on Feb 01, 2014 at 23:24 UTC | |
by AnomalousMonk (Archbishop) on Feb 02, 2014 at 08:29 UTC |