Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

tombom (5755)

tombom
  (email not shown publicly)

Journal of tombom (5755)

Friday March 18, 2005
02:37 PM

First time with Pugs

Today I decided to try and test Pugs to see how well it does. Here was my first try:

pugs> my x = 2
*** Error:
unexpected "x"
expecting variable name or "("
  at <interactive> at line 1, column 4
pugs> my $x = 2;
2
pugs> my $x = "a";
'a'
pugs> my $x is Int = "a";
*** Error: No compatible subroutine found: &is
  at App "&is" (App "&Int" (App "&prefix:=" (Syn "cxt"
                                             {'Str';
                                              App "&infix:~" ('a',
                                                              '')})))
pugs> my Int $x = 1;
*** Error:
unexpected "I"
expecting variable name or "("
  at <interactive> at line 1, column 4

That didn't go to well. So now I start reading some more synopses 'n' stuff and come up with this:

pugs> my $a = sub { say "a" }
sub {...}
pugs> $a->()
*** Error:
unexpected ">" or "-"
expecting word character, ":", term postfix, operator, postfix conditional, post
fix loop, postfix iteration, ";" or end of input
  at <interactive> at line 1, column 3
pugs> $a()
a
bool::true

Wayhey! Looks almost like perl5. And I can now produce this:

#!perl6
use v6;

my @tags = ("AMI ","ENG ","FRA ","SPA ","CAS ","A ","B ","C ","D ");

sub get_r_tags($a) {
    my @b = ();
    for(1..$a) {
        push @b, @tags[rand(@tags)];
    }
    return @b;
}

say get_r_tags(3);

Looks like there's hope for my CK random scenario thing in perl6 yet :)