tombom's Journal
http://use.perl.org/~tombom/journal/
tombom's use Perl Journalen-ususe 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:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00tombom's Journalhttp://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> my x = 2<br>*** Error:<br>unexpected "x"<br>expecting variable name or "("<br> at <interactive> at line 1, column 4<br>pugs> my $x = 2;<br>2<br>pugs> my $x = "a";<br>'a'<br>pugs> my $x is Int = "a";<br>*** Error: No compatible subroutine found: &is<br> at App "&is" (App "&Int" (App "&prefix:=" (Syn "cxt"<br> {'Str';<br> App "&infix:~" ('a',<br> '')})))<br>pugs> my Int $x = 1;<br>*** Error:<br>unexpected "I"<br>expecting variable name or "("<br> at <interactive> 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> my $a = sub { say "a" }<br>sub {...}<br>pugs> $a->()<br>*** Error:<br>unexpected ">" or "-"<br>expecting word character, ":", term postfix, operator, postfix conditional, post<br>fix loop, postfix iteration, ";" or end of input<br> at <interactive> at line 1, column 3<br>pugs> $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> my @b = ();<br> for(1..$a) {<br> push @b, @tags[rand(@tags)];<br> }<br> 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>tombom2005-03-18T19:37:39+00:00perl6