Raku By Example
View me onGitHub
## heredoc

my $heredoc = q:to/END/;
1001 	发现栏小程序主入口
1005 	顶部搜索框的搜索结果页
1006 	发现栏小程序主入口搜索框的搜索结果页
END

.say for $heredoc.split("\n");
.say for $heredoc.lines;

## qq heredoc

my @filenames = dir '.',  test => all(/\.md$/);

for @filenames -> $filePath {
    my $path = $filePath.path();
    $path ~~ s/.md//;

    my $date = DateTime.new(now);
    my $head =
qq:heredoc 'EOT';
title:  $path.IO.basename()
date: $date
tags: Perl6
categories: Perl 6
EOT

   my @content   = slurp $filePath;
   spurt($filePath.path, "$head\n@content[]");
}

## finish

for $=finish.lines -> $line {
    print $line  if $line ~~ m|^'<s>'$| ^ff^ $line ~~ m|^'</s>'$|;
}

=finish
<s>

一个
笑话
</s>

## --------------------------------------------------

for $=finish.lines -> $line {
    say 'insert into aladdin_user (name,password,gender,idgard,logo,sign,mail) values (' ~
      ($line.split: /<[\s+ |]>/, :skip-empty.&quote.join(",") ~ ");";
}

# 返回 insert into aladdin_user (name,password,gender,idgard,logo,sign,mail) values ("NULL","3de11d8ea894d9a77857b30454c61b66","1","NULL","NULL","BB","NULL");

sub quote(Str $ele) {
    return '"' ~ $ele ~ '"';
}

=finish
|NULL|3de11d8ea894d9a77857b30454c61b66|1|NULL|NULL|BB|NULL|