my $poem='larry Wall'; my @primes='Larry','boly','Wsaton'; my %dev='rakudo'=>'star','niecza'=>'perl6'; say Q :b /\t\n/; # tab and new line character say Q :s /$poem/; # content of $poem say Q :a /@primes[]/; # all number separated by single spaces say Q :a /@primes[0]/; # returns '2', the first prime say Q :a /me@primes.de/; # returns literally the mail adress, you need the square braces to interpolate arrays say Q :h /%dev{}/; # all developer names (values, not keys) separated by single spaces, angle brackets work too # say Q :h /%dev[rakudo] %dev<niecza>/; # just 2 values say Q :h /%dev/; # literally '%dev', you need braces here too say Q :c /There are {2**6} hexagrams in I Ging./; # returns: 'There are 64 hexagrams in I Ging.', inserts the result of the closure say Q :c /Perl 6 Compiler: {%dev.keys}./; # use it too for method calls say Q :h /Perl 6 Compiler: %dev.keys./; # no interpolation # say Q :f :a /Here it Tom with the weather: &fetch_report($day)./; # inserts report of that day, even inside Strings the correctness of arguments will be checked! # say Q :f :a /fetch_report($day)/; # interpolates just $day # say Q :f :a /&fetch_report/; # literal string '&fetch_report', even if the subroutine takes no arguments # sub fetch_report() { # say Q :s/today is $day/; # } say 'Welcome in Larry\'s madhouse'; say '\'\\'; # string contains: '\ say q |\||; # string contains: | ## Q 分割符 say Q/hello/; say Q{world}; say Q|1234|; say Q,comma,; say Q[maohao]; say Q*askiles*; say Q:a/@a[0]/; # 1 ## 中文引号 say “啊啊啊”; say '“'.uniname; # LEFT DOUBLE QUOTATION MARK say '“'.ord; # 8220 say 8220.chr; # “ say so '“' ~~ /<:Han>/; # False say "‘".uniname; # LEFT SINGLE QUOTATION MARK say "‘".ord; # 8216 say 8216.chr; # ‘ ## 插入标题 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 --- <blockquote class="blockquote-center">Rakudo Star</blockquote> [TOC] EOT my @content = slurp $filePath; spurt($filePath.path, "$head\n@content[]"); }