Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re^2: Getting for() to accept a tied array in one statement
by perlancar
|
|