develooper Front page | perl.perl6.language | Postings from July 2012

Re: [perl #113930] Lexical subs

Thread Previous
From:
Moritz Lenz
Date:
July 8, 2012 13:14
Subject:
Re: [perl #113930] Lexical subs
Message ID:
4FF9EA1B.80005@faui2k3.org
On 07/08/2012 09:57 PM, Father Chrysostomos via RT wrote:
>     my $x;
>     my sub f { say $x }
>     for 1..10 -> $x { f(); }

It prints

Any()
Any()
Any()
Any()
Any()
Any()
Any()
Any()
Any()
Any()

(because Any is the default value in uninitialized variables).

As an aside, you can run short Perl 6 scripts on IRC (on irc.perl.org
and irc.freenode.org) with something like

/msg p6eval p6: my $x; sub sub f { say $x }; for 1..10 -> $x { f() }

This runs it through both rakudo and niecza.

If you want, I can also send the bot into #p5p.

Cheers,
Moritz

Thread Previous


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