Raku By Example
View me onGitHub
## $*ARGFILES

$*ARGFILES.perl.say; #=> IO::Handle.new(:path(Any),:chomp)

# 按行读取
for $*ARGFILES.lines -> $line {
    say "$line";
}

# 一次性读取
# say $*ARGFILES.slurp;

## @*ARGS

say @*ARGS.WHAT;
say @*ARGS;

say @*ARGS.perl;

## $*CWD 

say $*CWD;
say $*CWD.path;
say $*CWD.perl;

## $*DISTRO

say $*DISTRO;

say $*DISTRO.name;
say $*DISTRO.is-win;
say $*DISTRO.version;

say $*DISTRO.path-sep;
say $*DISTRO.auth;
say $*DISTRO.desc;
say $*DISTRO.release;
say $*DISTRO.signature;

say $*DISTRO.gist;
say $*DISTRO.Str;
say $*DISTRO.perl;

## dynamic named arguments

multi f(:$named)     { note &?ROUTINE.signature };
multi f(:$also-named){ note &?ROUTINE.signature };

for 'named', 'also-named' -> $n {
	f(|($n => rand))     # «(:$named)␤(:$also-named)␤»
}

my $pair = :named(1);
f |$pair;

my %pairs = also-named => 4;
f |%pairs;

## $*ERR

say $*ERR.perl;
say $*ERR.path;
say $*ERR.chomp;

$*ERR.say("我错了");

## $*EXECUTABLE-NAME

say $*EXECUTABLE-NAME;
say $*EXECUTABLE.SPEC;
say $*EXECUTABLE.Str;
say $*EXECUTABLE.basename;

say $*EXECUTABLE-NAME.WHAT;
say $*EXECUTABLE.perl;

## $*USER

say $*USER;
say +$*USER;
say ~$*USER;

say $*USER.perl;

## $*GROUP

say $*GROUP;
say ~$*GROUP;
say +$*GROUP;

say $*GROUP.WHAT;
say $*GROUP.perl;

## $*HOME

say $*HOME;
say $*HOME.CWD;
say $*HOME.SPEC;

say $*HOME.WHAT;
say $*HOME.perl;

## $*IN

say $*IN.path;
say $*IN.chomp;

say $*IN.WHAT;
say $*IN.perl;

for $*IN.lines -> $line {
    say "$line";
}

## $*KERNEL

say $*KERNEL;
say $*KERNEL.release;
say $*KERNEL.name;
say $*KERNEL.auth;
say $*KERNEL.version;
say $*KERNEL.signature;
say $*KERNEL.desc;

say $*KERNEL.WHAT;
say $*KERNEL.perl;


## $*OUT

say $*OUT.perl;
say $*OUT.path;
say $*OUT.chomp;

$*OUT.say( q:to/新年快乐/ );
    祝你新年快乐
    2016.01.23
    让我再说一次
新年快乐

## $*PERL

say $*PERL;
say $*PERL.compiler;

say $*PERL.perl;

## $*PID

say $*PID;
say $*PID.perl;
say $*PID.WHAT;

## $*PROGRAM-NAME

say $*PROGRAM-NAME;
say $*PROGRAM-NAME.perl;
say $*PROGRAM-NAME.IO.basename;

## $*PROGRAM

say $*PROGRAM;
say $*PROGRAM.Str;
say $*PROGRAM.perl;
say $*PROGRAM.SPEC;
say $*PROGRAM.CWD;
say $*PROGRAM.WHAT;

## $*REPO

say $*REPO;
say $*REPO.perl;
say $*REPO.id;
say $*REPO.path-spec;
say $*REPO.loaded;
say $*REPO.repo-chain;

## $*SPEC

say $*SPEC;          #=> (Unix)
say $*SPEC.perl;     #=> IO::Spec::Unix
say $*SPEC.path;     #=> (/usr/local/Cellar/rakudo-star/2015.12/share/perl6/site/bin /usr/local/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin)
say $*SPEC.tmpdir;   #=> "/var/folders/9v/wr31l2zj78x1nw58jgljq_9w0000gn/T".IO
say $*SPEC.dir-sep;  #=> /
say $*SPEC.curdir;   #=> .
say $*SPEC.updir;    #=> ..
say $*SPEC.curupdir; #=> none(., ..)
say $*SPEC.rootdir;  #=> /
say $*SPEC.devnull;  #=> /dev/null

## $*TZ

# timezone
say $*TZ;
say $*TZ.perl;

say $*TZ.WHAT;

## $*VM

say $*VM;

say $*VM.config;
say $*VM.perl;