1#!/usr/bin/env perl6 2 3use v6; 4 5my $string = 'I look like a # comment!'; 6 7if $string eq 'foo' { 8 say 'hello'; 9} 10 11regex http-verb { 12 'GET' 13 | 'POST' 14 | 'PUT' 15 | 'DELETE' 16 | 'TRACE' 17 | 'OPTIONS' 18 | 'HEAD' 19} 20 21# a sample comment 22 23say 'Hello from Perl 6!' 24 25 26#`{ 27multi-line comment! 28} 29 30say 'here'; 31 32#`( 33multi-line comment! 34) 35 36say 'here'; 37 38#`{{{ 39I'm a special comment! 40}}} 41 42say 'there'; 43 44#`{{ 45I'm { even } specialer! 46}} 47 48say 'there'; 49 50#`{{ 51does {{nesting}} work? 52}} 53 54#`«< 55trying mixed delimiters 56» 57 58my $string = qq<Hooray, arbitrary delimiter!>; 59my $string = qq«Hooray, arbitrary delimiter!»; 60my $string = q <now with whitespace!>; 61my $string = qq<<more strings>>; 62 63my %hash := Hash.new; 64 65=begin pod 66 67Here's some POD! Wooo 68 69=end pod 70 71=for Testing 72 This is POD (see? role isn't highlighted) 73 74say('this is not!'); 75 76=table 77 Of role things 78 79say('not in your table'); 80#= A single line declarator "block" (with a keyword like role) 81#| Another single line declarator "block" (with a keyword like role) 82#={ 83 A declarator block (with a keyword like role) 84 } 85#|{ 86 Another declarator block (with a keyword like role) 87 } 88#= { A single line declarator "block" with a brace (with a keyword like role) 89#=« 90 More declarator blocks! (with a keyword like role) 91 » 92#|« 93 More declarator blocks! (with a keyword like role) 94 » 95 96say 'Moar code!'; 97 98my $don't = 16; 99 100sub don't($x) { 101 !$x 102} 103 104say don't 'foo'; 105 106my %hash = ( 107 :foo(1), 108); 109 110say %hash<foo>; 111say %hash<<foo>>; 112say %hash«foo»; 113 114say %*hash<foo>; 115say %*hash<<foo>>; 116say %*hash«foo»; 117 118say $<todo>; 119say $<todo>; 120 121for (@A Z @B) -> $a, $b { 122 say $a + $b; 123} 124 125Q:PIR { 126 .loadlib "somelib" 127} 128 129my $longstring = q/ 130 lots 131 of 132 text 133/; 134 135my $heredoc = q:to/END_SQL/; 136SELECT * FROM Users 137WHERE first_name = 'Rob' 138END_SQL 139my $hello; 140 141# Fun with regexen 142 143if 'food' ~~ /foo/ { 144 say 'match!' 145} 146 147my $re = /foo/; 148my $re2 = m/ foo /; 149my $re3 = m:i/ FOO /; 150 151call-a-sub(/ foo /); 152call-a-sub(/ foo \/ bar /); 153 154my $re4 = rx/something | something-else/; 155my $result = ms/regexy stuff/; 156my $sub0 = s/regexy stuff/more stuff/; 157my $sub = ss/regexy stuff/more stuff/; 158my $trans = tr/regexy stuff/more stuff/; 159 160my @values = <a b c d>; 161call-sub(<a b c d>); 162call-sub <a b c d>; 163 164my $result = $a < $b; 165 166for <a b c d> -> $letter { 167 say $letter; 168} 169 170sub test-sub { 171 say @_; 172 say $!; 173 say $/; 174 say $0; 175 say $1; 176 say @*ARGS; 177 say $*ARGFILES; 178 say &?BLOCK; 179 say ::?CLASS; 180 say $?CLASS; 181 say @=COMMENT; 182 say %?CONFIG; 183 say $*CWD; 184 say $=data; 185 say %?DEEPMAGIC; 186 say $?DISTRO; 187 say $*DISTRO; 188 say $*EGID; 189 say %*ENV; 190 say $*ERR; 191 say $*EUID; 192 say $*EXECUTABLE_NAME; 193 say $?FILE; 194 say $?GRAMMAR; 195 say $*GID; 196 say $*IN; 197 say @*INC; 198 say %?LANG; 199 say $*LANG; 200 say $?LINE; 201 say %*META-ARGS; 202 say $?MODULE; 203 say %*OPTS; 204 say %*OPT; 205 say $?KERNEL; 206 say $*KERNEL; 207 say $*OUT; 208 say $?PACKAGE; 209 say $?PERL; 210 say $*PERL; 211 say $*PID; 212 say %=pod; 213 say $*PROGRAM_NAME; 214 say %*PROTOCOLS; 215 say ::?ROLE; 216 say $?ROLE; 217 say &?ROUTINE; 218 say $?SCOPE; 219 say $*TZ; 220 say $*UID; 221 say $?USAGE; 222 say $?VM; 223 say $?XVM; 224} 225 226say <a b c>; 227 228my $perl5_re = m:P5/ fo{2} /; 229my $re5 = rx«something | something-else»; 230 231my $M := %*COMPILING<%?OPTIONS><M>; 232 233say $M; 234 235sub regex-name { ... } 236my $pair = role-name => 'foo'; 237$pair = rolesque => 'foo'; 238 239my sub something(Str:D $value) { ... } 240 241my $s = q«< 242some 243string 244stuff 245»; 246 247my $regex = m«< some chars »; 248# after 249 250say $/<foo><bar>; 251 252roleq; 253