Blog of Gabor Szabo http://szabgab.com Gabor Szabo about Perl, automated testing, dynamic languages and everyting else en-us Copyright 2002-2010, Gabor Szabo szabgab@gmail.com 1901-01-01T00:00+00:00 1 hourly Fundamentals of Perl training in October, 2010, in Ramat Gan http://szabgab.com/blog/2010/08/fundamentals-of-perl-training-october-2010-ramat-gan.html <p> After a long period that I was giving only on-site classes finally I decided that it might be time to start offering the "public registration" classes as well. </p> <p> It is a lot more work to organize such class as I need to be in touch with several customers and there were cases when people cancelled their participation in the last minute but recently several companies indicated that they would like to send 1-2 people to such class so I hope it won't be that hard </p> <p> The syllabus of the <a href="http://pti.co.il/fundamentals.html">Fundamentals of Perl</a> training is on the web site of <a href="http://pti.co.il/">PTI</a> but actually the whole <a href="http://szabgab.com/fundamentals_of_perl.html">material</a> can be found on my web site. </p> Gabor Szabo 2010-08-22T20:13:51+00:00 Perl, training, Israel Perl 6 subroutines and home made operators http://szabgab.com/blog/2010/08/perl6-subroutines-and-home-made-operators.html <p> <h2>Welcome back to the Perl 6 Tricks and Treats</h2> </p> <p> This time together with a Perl 6 screencast to show the <b>thought operator</b> and the <b>+- operator</b> of Perl 6. Direct link to the <a href="http://www.youtube.com/watch?v=sBvjUi2093A">Perl 6 subroutines screencast</a> </p> <p> <hr> This entry was first sent out as part of the <a href="http://szabgab.com/perl6_tricks_and_treats.html">Perl 6 Tricks and Treats</a>. Visit <a href="http://mail.szabgab.com/mailman/listinfo/perl6">here to subscribe</a>.<br> It was also included the <a href="http://szabgab.com/perl6.html">Perl 6 series of screencasts</a>. <hr> </p> <p> <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/sBvjUi2093A?fs=1&amp;hl=en_US"> </param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/sBvjUi2093A?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object> </p> <p> <h2>The Thought operator</h2> </p> <p> I just tried the thought operator in Perl 6. Typed in this: </p> <pre> "szabgab" .oO "Perl 6 is cool"; </pre> <p> and got the following: </p> <pre> szabgab thinks Perl 6 is cool </pre> <p> <h2>The +- operator</h2> </p> <p> I also tried the +- operator: </p> <pre> 2.78 ~~ 10 +- 3 ?? 't' !! 'f' # f 7.5 ~~ 10 +- 3 ?? 't' !! 'f' # t 13 ~~ 10 +- 3 ?? 't' !! 'f' # t 13.1 ~~ 10 +- 3 ?? 't' !! 'f' # f </pre> <p> I think you get the point here. We check if the value on the left is between 10 +- 3. </p> <p> ~~ is the smart match operator, ?? !! are the two parts of the ternary operator of Perl 6 and +- is, well not everyone has the +- or the thought operator but if you read on you'll see how you can create one for yourself. </p> <p> <h2>Subroutines in Perl 6</h2> </p> <p> Subroutines in Perl 6 are declared using the sub keyword just as in Perl 5 But in Perl 6, after the name of the subroutine one can provide a signature, describing the parameters that function accepts. </p> <pre> use v6; sub f($a, $b) { return "$a - $b"; } say f(4, 2); </pre> <p> If called with a different number of arguments then Perl will issue an error message: </p> <pre> say f(4, 2, 5); </pre> <p> gives this message: </p> <pre> Too many positional parameters passed; got 3 but expected 2 in 'f' at line 3:script.p6 in main program body at line 8:script.p6 </pre> <p> or </p> <pre> say f(4); </pre> <p> gives this message: </p> <pre> Not enough positional parameters passed; got 1 but expected 2 in 'f' at line 3:script.p6 in main program body at line 8:script.p6 </pre> <p> <h2>Perl 5 style in Perl 6</h2> </p> <p> For people who really want the Perl 5 style subroutine declaration they can use this code: </p> <pre> use v6; sub f { return @_.perl } say f(4, 2); # [4, 2] say f(4); # [4] say f(4, 2, 3); # [4, 2, 3] </pre> <p> but that would eliminate all the nice features of Perl 6. </p> <p> <h2>Optional parameter</h2> </p> <p> What if we would like to allow the user to pass 1 or 2 parameters? For that case we can mark the second parameter as optional: </p> <pre> use v6; sub f($a, $b?) { return defined $b ?? "$a - $b" !! "$a - na"; } say f(4, 2); # 4 - 2 say f(4); # 4 - na </pre> <p> The ?? !! is a the ternary operator of Perl 6 so what we see above is that if $b is defined the "$a - $b" is returned and when $b is not defined then 'na' will be returned instead of that value. </p> <p> <h2>Parameters are read-only</h2> </p> <p> In other cases you might be tempted to replace $b with some default value like this: </p> <pre> use v6; sub f($a, $b?) { $b //= 17; return defined $b ?? "$a - $b" !! "$a - na"; } say f(4, 2); # 4 - 2 say f(4); # 4 - na </pre> <p> but this will throw an exception like this: </p> <pre> Cannot modify readonly value in '&infix:&lt;=&gt;' at line 1 in 'f' at line 4:02.p6 in main program body at line 8:02.p6 </pre> <p> as arguments in Perl 6 are by default read only; </p> <p> <h2>Default value of a parameter</h2> </p> <p> There are two solutions to this, depending on what do you really want to achieve: If you only want to give a default value to $b then the best way is to add it right in the signature: </p> <pre> use v6; sub f($a, $b = 17) { return defined $b ?? "$a - $b" !! "$a - na"; } say f(4, 2); # 4 - 2 say f(4); # 4 - 17 </pre> <p> In this case you don't even need the question mark '?' as the presence of a default value automatically makes the parameter optional. This still keeps $b read-only within the subroutine. </p> <p> <h2>Making the parameter a copy and thus changeable</h2> </p> <p> The other solution is to mark the $b variable as a 'copy' of the original value. Therefore allowing the user to make changes to it: </p> <pre> use v6; sub f($a, $b? is copy) { $b //= 17; return defined $b ?? "$a - $b" !! "$a - na"; } say f(4, 2); # 4 - 2 say f(4); # 4 - 17 </pre> <p> <h2>Type restrictions on parameters</h2> </p> <p> We can also restrict the parameters of a subroutine to certain data types: </p> <pre> use v6; sub f($a, Int $b) { return "$a - $b"; } say f(4, 2); say f(4, "foo"); </pre> <p> The first call will succeed but the second will generate an exception: </p> <pre> 4 - 2 Nominal type check failed for parameter '$b'; expected Int but got Str instead in 'f' at line 4:03.p6 in main program body at line 9:03.p6 </pre> <p> <h2>Other constraints on parameters</h2> </p> <p> It is also possible to provide further constraints on the parameters: </p> <pre> use v6; sub f($a, Int $b where { $b &lt; 10 }) { return "$a - $b"; } say f(4, 2); say f(4, 11); 4 - 2 Constraint type check failed for parameter '$b' in 'f' at line 4:03.p6 in main program body at line 9:03.p6 </pre> <p> <h2>Creating operators in Perl 6</h2> </p> <p> There are of course a lot of other aspects for subroutine definition in Perl 6 but let's now go back to our original goal, to create the +- operator. </p> <p> So how can one create a new operator in Perl 6? It is quite simple as an operator is just a subroutine with a funny way of calling it. </p> <p> So here is how to create the thought operator. We create a subroutine, declaring it to be an infix operator with the name .oO </p> <pre> sub infix:&lt;.oO&gt;($name, $thought) { say "$name thinks $thought" } </pre> <p> Specifically we want to make +- an infix operator that create a Range. Not something complex. Within the angle brackets we put the new operator, the sub has a signature of two scalars and within the block we put actual code that needs to be executed. </p> <pre> sub infix:&lt;+-&gt;($a, $b) { ($a-$b) .. ($a+$b) } </pre> <p> Then we can use </p> <pre> 5 +- 2 </pre> <p> that will create the range 5-2 .. 5+2 also known as 3 .. 7 </p> <p> <h2>Comments and Discussion</h2> </p> <p> I am always open to comments and criticism (just have a positive spin to it :-) So if you find any issue with the examples, please don't hesitate to let me know. </p> <p> If you'd like to ask question about Perl 6, probably the best would be to sign up on the Perl 6 users list by sending an e-mail to </p> <pre> perl6-users-subscribe@perl.org </pre> <p> The archive of the perl6-users list is at: <a href="http://www.perl6.org/">Perl6.org</a> </p> <p> The even better way is to join the #perl6 IRC channel on irc.freenode.net If you have not used IRC yet, the easies way is to use the web based <a href="http://webchat.freenode.net/?channels=perl6">IRC client of Freenode</a> </p> <p> Previous issues of this newsletter can be found at <a href="http://szabgab.com/perl6_tricks_and_treats.html">Perl 6 Tricks and Treats</a>. </p> Gabor Szabo 2010-08-15T15:10:12+00:00 Perl, Perl 6, learning, newsletter, screencast, subroutines, Rakudo More Perl events in 2010 http://szabgab.com/blog/2010/08/more-perl-events-in-2010.html <p> Yesterday I wrote about tech events with some Perl content <a href="http://szabgab.com/blog/2010/08/upcoming-events-for-promoting-perl.html">Perl::Staff - Upcoming events for promoting Perl</a>. This time let me list the upcoming Perl events: </p> <p> The <a href="http://pghpw.org/">Pittsburgh Perl Workshop 2010</a> will take place between 9-10 October in, well, Pittsburgh, Pennsylvania. </p> <p> <a href="http://act.osdc.fr/osdc2010fr/">OSDC.fr</a> is not strictly a Perl event but AFAIK it is organized by the French Perl Mongueurs. It will be on the same dates 9-10 October, in Paris, France. </p> <p> <a href="http://yapcasia.org/2010/">YAPC::Asia</a> October 14-16 in Tokyo, Japan. </p> <p> The <a href="http://conferences.yapceurope.org/apw2010/">Austrian Perl Workshop</a> will take place later this year in Vienna, Austria. (no fixed date yet). </p> <p> <a href="http://www.osdc.com.au/">OSDC Australia</a> will take place betwee 24-26 November, 2010 in Melbourne. </p> <p> The <a href="">Russian Perl Workshop</a> between December 18, 2010 in Saint Petersburg, Russia </p> <p> The London Perl Workshop usually takes place in December. No website yet. </p> <p> That's it for 2010 as far as I know. </p> Gabor Szabo 2010-08-12T01:21:45+00:00 Perl, events, OSDC, Perl Workshop Perl::Staff - Upcoming events for promoting Perl http://szabgab.com/blog/2010/08/upcoming-events-for-promoting-perl.html <p> As I mentioned during my lightning talk in Pisa there are a number of tech events in Europe where it would be interesting to have Perl presence. The full list of events that I am aware of can be found on the <a href="http://www.perlfoundation.org/perl5/index.cgi?events">events</a> wiki page and the Perl presence is being organized for some of them already. </p> <p> If you have time it would be nice to help out the organizers or if you can attend other events, then to organize something there or if you know about more events, please add them to the wiki. </p> <p> Here is what is planned so far: </p> <p> <a href="http://www.perlfoundation.org/perl5/index.cgi?events_2010_froscon">Froscon</a> in St Augustin, Germany will take place 21-22 August 2010. Organized by Renée Bäcker there is going to be a full track of Perl talks. </p> <p> <a href="http://www.perlfoundation.org/perl5/index.cgi?events_2010_froscamp_zurich">FrosCamp</a> in Zurich, Switzerland will be 17-18 September 2010. Oranized by Renée Bäcker, as I can see there is going to be a Perl booth and maybe a couple of Perl related talks. The dead-line for talk submission is 2010-08-14. Just a few days from now. </p> <p> <a href="http://www.perlfoundation.org/perl5/index.cgi?events_2010_oswc_malaga">OSWC</a> in Malaga, Spain between 27-28 October 2010. The organizers, Salvador Fandiño, Diego Kuperman, JJ Merelo, Rodrigo de Oliveira are planning to have a Perl track. </p> <p> <a href="http://www.perlfoundation.org/perl5/index.cgi?events_2010_blit_potsdam">Brandenburger Linux-Infotag</a> in Potsdam, Germany on 6 Nov 2010. Organized by Renée Bäcker they are stll looking for more people to help out at the Perl booth and give Perl related talks. </p> <p> <a href="http://www.perlfoundation.org/perl5/index.cgi?events_2010_t_dose_eindhoven">T-Dose</a> in Eindhoven, Holland will be between 6-7 November 2010. I've just started to organize the Perl presence there. Let me know if you can help out. </p> Gabor Szabo 2010-08-10T19:56:52+00:00 events, Germany, Switzerland, Spain, Holland, promotion, Perl YAPC::EU 2010 Pisa http://szabgab.com/blog/2010/08/yapc-eu-2010-pisa.html <p> I really enjoyed myself in Pisa. Thanks for all the organizers of <a href="http://conferences.yapceurope.org/ye2010/">YAPC::EU</a> and the speakers and all the attendees. The event was really awesome! </p> <p> After spending most of my time at YAPC::NA in the hallway track trying to talk about <a href="http://news.perlfoundation.org/2010/06/hague-grant-application-perl-e.html">my grant proposal</a> and after being discouraged by some of the negative comments there I decided to try to spend a lot more time in talks and not to initiate discussion about it. Still many people stopped me in breaks and asked me about my grant. I tried to give them a status report and in most cases they tried to encourage me to keep going with it. </p> <p> I also talked to Allison Randal about the grant and as far as I understand she said the TPF will never approve my grant. She did not say what is her opinion and if she would vote for it, but she was one of the people who told me a few month ago that instead of trying to setup a separate organization for this I should do it within The Perl Foundation. </p> <p> Actually I think she said that the only thing that can bring Perl back to its fame is a company doing a very interesting and high-profile project in it. Similar to how the work of <a href="http://37signals.com/">37 Signals</a> releasing Rails made Ruby interesting. </p> <p> Allison also said that instead of asking for a grant I should just organize more events and try to raise money for them from companies. I just wonder, if I take all the risk then why should that be within TPF? </p> <p> After her advantures in getting to YAPC, finally Karen Pauley and me also had some time to discuss the grant. I think this was very important thought I am not sure we have managed to move forward. At least now I understand much better the varous things she needs to ballance as the president of TPF. Frankly, I don't think many people would be able to do that and I am quite afraid that she will burn out and then the TPF will stop making any progress. </p> <p> I won't list here all the other nice people I met at YAPC as that would take ages but I'd like to say again thanks to the organizers and all the people who participated! </p> <p> Some <a href="http://www.flickr.com/search/?w=all&q=yapceu2010">pictures of YAPC::EU 2010 in Pisa</a>. </p> Gabor Szabo 2010-08-09T09:54:38+00:00 Perl, YAPC, conferences, hackathons Perl 6 screencast - part 5 - hashes http://szabgab.com/blog/2010/07/introduction-to-perl6-screencast-hashes.html <p> Direct link to the <a href="http://www.youtube.com/watch?v=Cm0y9p9QYs4">Perl 6 screencast about hashes</a> </p> <p> <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Cm0y9p9QYs4&hl=en&fs=1"> </param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"> </param><embed src="http://www.youtube.com/v/Cm0y9p9QYs4&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> </p> <p> See more <a href="http://szabgab.com/perl6.html">Perl 6</a> entries. </p> <p> <h2>Perl 6 Code examples</h2> </p> <p> Hashes in Perl 6 are denoted using % sign: Creating a hash </p> <pre> my %h = "Foo" =&gt; 1, "Bar" =&gt; 2; </pre> <p> printing it out for debugging purposes: </p> <pre> say %h.perl; # {"Foo" =&gt; 1, "Bar" =&gt; 2} </pre> <p> printing the value of a single key: </p> <pre> say %h{"Foo"}; # 1 </pre> <p> The quotation marks are required around the string: </p> <pre> say %h{Foo}; # Could not find sub &Foo </pre> <p> You can use variables without quoting them: </p> <pre> my $name = "Foo"; say %h{$name}; # 1 </pre> <p> Recall from the previus section that you can use the angle brackets to quote a number of strings and create a list of them: </p> <pre> say &lt;Foo Bar&gt;; # FooBar </pre> <p> This notation can be used to eliminate the need for quotation marks: </p> <pre> say %h&lt;Foo&gt;; # 1 </pre> <p> You can actually use multiple keys there fetching a list of values of a hash slice: </p> <pre> say %h&lt;Foo Bar&gt;; # 1 2 </pre> <p> Using the "perl" method just further proves that you get back a list of values </p> <pre> say %h&lt;Foo Bar&gt;.perl; # (1, 2) </pre> <p> In order to fetch all the keys you can use the ".keys" method and then you can iterate over the individual keys and fetch the respective values: </p> <pre> for %h.keys -&gt; $k { say "$k %h{$k}"; } </pre> <p> There is also a ".values" method that will return the list of values. Even though in our case the values are unique in the general case you cannot easily get back the keys from the values: </p> <pre> for %h.values -&gt; $v { say $v; } </pre> <p> In case you prefere to iterate over the key-value pairs for that you can use the ".kv" method: </p> <pre> for %h.kv -&gt; $k, $v { say "$k - $v"; } </pre> <p> To add another key with its value you can use the following code: </p> <pre> %h&lt;Moo&gt; = 3; say %h.perl; # {"Moo" =&gt; 3, "Foo" =&gt; 1, "Bar" =&gt; 2} </pre> <p> If the key already exists this will replace the value in the hash: </p> <pre> %h&lt;Moo&gt; = 4; say %h.perl; # {"Moo" =&gt; 4, "Foo" =&gt; 1, "Bar" =&gt; 2} </pre> <p> On the other hand in Perl 6 you can also use the ".push" method on a hash that will add the value to the given key creating an array as the value of that key: </p> <pre> %h.push( 'Moo' => 5 ); say %h.perl; # {"Moo" => [4, 5], "Foo" => 1, "Bar" => 2} </pre> Gabor Szabo 2010-07-31T14:49:30+00:00 Perl 6, Perl, screencast, hashes Happy 2nd birthday to Padre - Get on an IRC channel http://szabgab.com/blog/2010/07/happy-2nd-birthday-to-padre-the-perl-ide.html <p> The <a href="http://padre.perlide.org/irc.html">IRC redirector</a> on the <a href="http://padre.perlide.org/">Padre</a> website. Type in some username and select the channel. </p> <p> If your perl related channel is missing from the list let us know on #padre irc.perl.org </p> <p> I hope you'll come by the Padre channel and say happy birthday to the developers! </p> <p> <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/oQjYzneEBmw&hl=en&fs=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/oQjYzneEBmw&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> </p> <p> Direct link to the <a href="http://www.youtube.com/watch?v=oQjYzneEBmw">screencast</a> </p> Gabor Szabo 2010-07-24T15:55:45+00:00 Perl, Padre, screencast, IRC How to connect to the #perl6 IRC channel and try Perl 6 on-line http://szabgab.com/blog/2010/07/how-to-use-perl6-without-installing-it.html <pre> </pre> <p> Direct link to the <a href="http://www.youtube.com/watch?v=2M3f3uAqMWg">screencast</a> </p> <p> <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/2M3f3uAqMWg&amp;hl=en_US&amp;fs=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/2M3f3uAqMWg&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> </p> <p> See more <a href="http://szabgab.com/perl6.html">Perl 6</a> entries. </p> <p> <a href="http://webchat.freenode.net/">web interface to Freenode</a>. Pick some username and type in the name of the channel: #perl6 </p> Gabor Szabo 2010-07-23T17:45:44+00:00 Perl, Perl 6, screencast, tutorial, IRC Perl 6 screencast - part 4 - files http://szabgab.com/blog/2010/07/introduction-to-perl6-screencast-files.html <pre> </pre> <p> Direct link to the <a href="http://www.youtube.com/watch?v=hma55uL9qPI">Perl 6 files screencast</a> </p> <p> <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/hma55uL9qPI&amp;hl=en_US&amp;fs=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/hma55uL9qPI&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> </p> <p> See more <a href="http://szabgab.com/perl6.html">Perl 6</a> entries. </p> <p> <h2>Perl 6 Code examples</h2> </p> <p> Reading in all the lines of a file in a single scalar using the <i>slurp</i> function: </p> <pre> use v6; my $content = slurp "text.txt"; say $content.chars; </pre> <p> Reading in all the lines of a file into the first element of an array using the <i>slurp</i>: </p> <pre> use v6; my @content = slurp "text.txt"; say @content.elems; say @content[0].chars; </pre> <p> Reading in all the lines, each line in a separate element of the array using the <i>lines</i> function: </p> <pre> use v6; my @content = lines "text.txt"; say @content.elems; say @content[0].chars; </pre> <p> Iterating over the lines one by one. <i>lines</i> is evaluated lazily here: </p> <pre> use v6; for lines "text.txt" -&gt; $line { say $line.chars; } </pre> <p> Opening a file using the <i>open</i> function. Reading in one line using the <i>get</i> method. Iterating over the rest of the file using the <i>lines</i> method: </p> <pre> use v6; my $fh = open "text.txt"; my $first_line = $fh.get; say $first_line; for $fh.lines -&gt; $line { say $line.chars; } </pre> <p> Opening a file for writing, printing a string to it using the <i>say</i> method and then <i>close</i>ing it to flush all the buffered output. Then re-reading the file just to show what happened. </p> <pre> use v6; my $fh = open "out.txt", :w; $fh.say("text 4"); $fh.close; say slurp "out.txt"; </pre> Gabor Szabo 2010-07-23T02:05:45+00:00 Perl 6, Perl, screencast, files Perl 6 screencast - part 3 - arrays and ranges http://szabgab.com/blog/2010/07/introduction-to-perl6-screencast-arrays-and-ranges.html <p> Direct link to the <a href="http://www.youtube.com/watch?v=tqxI7L5FQ4w">Perl 6 arrays and ranges screencast</a> </p> <p> <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/tqxI7L5FQ4w&amp;hl=en_US&amp;fs=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/tqxI7L5FQ4w&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> </p> <p> See more <a href="http://szabgab.com/perl6.html">Perl 6</a> entries. </p> <p> <h2>Perl 6 Code examples</h2> </p> <pre> use v6; my @people = <Foo 123 Bar 456 Moo 789 Foo 512>; for @people -> $n { say $n; } use v6; my @people = <Foo 123 Bar 456 Moo 789 Foo 512>; for 0 .. @people.elems/2 -> $i { say "@people[$i*2] - @people[$i*2+1]"; } use v6; my @people = <Foo 123 Bar 456 Moo 789 Foo 512>; for @people -> $name, $phone { say "$name - $phone"; } use v6; my @names = <Foo Bar Moo Foo>; my @phones = <123 456 789 512>; for @names Z @phones -> $name, $phone { say "$name - $phone"; } use v6; for 1 .. 10 -> $n { say $n; } use v6; for 1,3 ... Inf -> $n { say $n; last if $n > 10; } </pre> Gabor Szabo 2010-07-22T11:38:18+00:00 Perl 6, Perl, screencast, arrays, ranges