Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^9: Getting for() to accept a tied array in one statement

by Veltro (Hermit)
on Apr 19, 2019 at 08:35 UTC ( [id://1232795]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Getting for() to accept a tied array in one statement
in thread Getting for() to accept a tied array in one statement

I absolutely agree with that too. I just interpreted a different intent:

for (tie @ary, "My::Class", "some", "el", "ems") { ... } # NOPE # This makes for() only loops over a single value, the tied object.

If the intention was to iterate over the 'object' then a possible solution would be to use a de-reference. However I felt this would be a bad idea and decided to point this out.

But it doesn't matter, everyone has proposed solutions that are much better. Esp. the solution hdb has found now using the lvalue sub is absolutely fantastic.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-23 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found