Just another Perl shrine | |
PerlMonks |
Re^11: Getting for() to accept a tied array in one statementby ikegami (Patriarch) |
on Apr 20, 2019 at 12:32 UTC ( [id://1232832]=note: print w/replies, xml ) | Need Help?? |
But that's what the OP wants, assuming the code the OP wants to execute for each element specifically fetches or generates the element to be returned. If that's not what the OP wants, there's no point to their wrapper, so there's no point to a tied array or iterator. They should simply place the logic in the loop itself. The rest of your post makes no sense. You only need three implementations with an iterator if you have three implementations with a tied array since the tied array approach is literally being used as an iterator (a role it is badly equipped to handle). The tied array is pure needles complexity and overhead, the very thing programmers should be avoiding. It adds absolutely no value. Tied arrays are a hack that should only be used to shoehorn logic into existing bad code. The very idea of a tied variable (to make code look like variable) is a bad practice. They should be used as a last resort. They should definitely be avoided when they are costly and don't provide any benefits like in this case.
In Section
Seekers of Perl Wisdom
|
|