|
|
| There's more than one way to do things | |
| PerlMonks |
Re^2: Getting for() to accept a tied array in one statementby perlancar (Hermit) |
| on Apr 16, 2019 at 13:12 UTC ( [id://1232649]=note: print w/replies, xml ) | Need Help?? |
|
for (tie @ary, "My::Class", "some", "contents") { ... } # NOPE does not work because for() gets a single-element list which is the tied object, not the tied array itself. for (do { tie @ary, "My::Class", "some", "contents"; @ary }) { ... } #NOPEdoes not work because for() gets an ordinary (non-magical) list of values. All the values from the tied array have been FETCH-ed. I need to iterate over the tied array so code inside the loop block and FETCH are executed once for each element, together.
works, but I want something more similar to:
where @ary is an ordinary array or a list of values.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||