tombom's Journal http://use.perl.org/~tombom/journal/ tombom's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:47:20+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 tombom's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~tombom/journal/ First time with Pugs http://use.perl.org/~tombom/journal/23724?from=rss Today I decided to try and test Pugs to see how well it does. Here was my first try:<blockquote><div><p> <tt>pugs&gt; my x = 2<br>*** Error:<br>unexpected "x"<br>expecting variable name or "("<br>&nbsp; at &lt;interactive&gt; at line 1, column 4<br>pugs&gt; my $x = 2;<br>2<br>pugs&gt; my $x = "a";<br>'a'<br>pugs&gt; my $x is Int = "a";<br>*** Error: No compatible subroutine found: &amp;is<br>&nbsp; at App "&amp;is" (App "&amp;Int" (App "&amp;prefix:=" (Syn "cxt"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{'Str';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; App "&amp;infix:~" ('a',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '')})))<br>pugs&gt; my Int $x = 1;<br>*** Error:<br>unexpected "I"<br>expecting variable name or "("<br>&nbsp; at &lt;interactive&gt; at line 1, column 4</tt></p></div> </blockquote><p>That didn't go to well. So now I start reading some more synopses 'n' stuff and come up with this:</p><blockquote><div><p> <tt>pugs&gt; my $a = sub { say "a" }<br>sub {...}<br>pugs&gt; $a-&gt;()<br>*** Error:<br>unexpected "&gt;" or "-"<br>expecting word character, ":", term postfix, operator, postfix conditional, post<br>fix loop, postfix iteration, ";" or end of input<br>&nbsp; at &lt;interactive&gt; at line 1, column 3<br>pugs&gt; $a()<br>a<br>bool::true</tt></p></div> </blockquote><p>Wayhey! Looks almost like perl5. And I can now produce this:</p><blockquote><div><p> <tt>#!perl6<br>use v6;<br> <br>my @tags = ("AMI ","ENG ","FRA ","SPA ","CAS ","A ","B ","C ","D ");<br> <br>sub get_r_tags($a) {<br>&nbsp; &nbsp; my @b = ();<br>&nbsp; &nbsp; for(1..$a) {<br>&nbsp; &nbsp; &nbsp; &nbsp; push @b, @tags[rand(@tags)];<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return @b;<br>}<br> <br>say get_r_tags(3);</tt></p></div> </blockquote><p>Looks like there's hope for my CK random scenario thing in perl6 yet<nobr> <wbr></nobr>:)</p> tombom 2005-03-18T19:37:39+00:00 perl6