develooper Front page | perl.perl6.language | Postings from September 2005

Re: for $arrayref {...}

Thread Previous | Thread Next
From:
Juerd
Date:
September 1, 2005 12:41
Subject:
Re: for $arrayref {...}
Ingo Blechschmidt skribis 2005-09-01 20:29 (+0200):
>     for ($arrayref,) {...};  # loop body executed only one time

Yes: scalar in list context.

>     for ($arrayref)  {...};  # loop body executed one or three times?

Same thing: scalar in list context. So once.

>     for  $arrayref   {...};  # loop body executed one or three times?

Same thing: scalar in list context. So once.

Scalars only automatically dereference in *specific* contexts. An
arrayref not used in Array context is still an arrayref, a hashref not
used in Hash context is still a hashref.

Pay attention to list context not being Array context. It does not
dereference anything.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About