Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Dereference string in foreach

by 7stud (Deacon)
on Feb 13, 2013 at 23:23 UTC ( #1018657=note: print w/replies, xml ) Need Help??


in reply to Dereference string in foreach

By the way, in "Perl Best Practices" Damian Conway advises that you should always write 'my' before your for-loop variable because if you don't :

[The resulting] behaviour is contrary to all reasonable expectation.  Everywhere else in Perl, when you declare a lexical variable, it's visible throughout the remainder of its scope, unless another explicit my declaration hides it.  So it's natural to expect that the [variable] used in the for loop is the same lexical [variable] that was declared before the loop.

But it isn't.
("Perl Best Practices", p. 108)

My code makes it neccessary to loop through an array and to output all elements using a reference.

That doesn't seem to make a lot of sense:

use strict; use warnings; use 5.010; my @arr = (10, 20, 30); for my $num (@arr) { say ${\$num}; } --output:-- 10 20 30

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018657]
help
Chatterbox?
[ambrus]: I think the minimal implementation here is just a timer and io function, plus pushing to the @REGISTRY.
[Corion]: ambrus: Yeah, at least that's what I think I'll start with. A timer and potentially the dummy IO function that never is ready
[ambrus]: That only lets you invoke the main loop from Prima->run;, not from AnyEvent->condvar- >recv; but that shouldn't matter

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2016-12-08 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.