Example 2-16. examples/scalars/string_functions_substr.p6
#!/usr/bin/perl6 my $s = "The black cat climbed the green tree"; my $z; $z = substr $s, 4, 5; # $z = black say $z; $z = substr $s, 4, -11; # $z = black cat climbed the say $z; $z = substr $s, 14; # $z = climbed the green tree say $z; $z = substr $s, -4; # $z = tree say $z; $z = substr $s, -4, 2; # $z = tr say $z; $z = substr $s, 14, 7, "jumped from"; # $z = climbed say $z; say $s; # $s = The black cat jumped from the green tree
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| String functions: index | Up | Super-or (junctions) |