#!/usr/bin/env stryke
use strict
use warnings
my $text = "The quick brown fox jumps over the lazy dog"
print "upper: ", $text |> uc, "\n"
print "lower: ", $text |> lc, "\n"
print "ucfirst: ", $text |> ucfirst, "\n"
print "length: ", $text |> len, "\n"
print "substr(0,9): ", substr $text, 0, 9), "\n"
print "index(fox): ", index $text, "fox"), "\n"
print "reverse: ", (split "", $text |> reverse) |> join "", "\n"
my @words = split " ", $text
print "word count: ", @words |> scalar, "\n"
print "words: ", @words |> join " | ", "\n"
my $copy = $text
$copy =~ s/fox/cat/
print "substituted: ${copy}\n"
if ($text =~ /(\w+)\s+(\w+)$/) {
print "last two words: ${1} ${2}\n"
}
my @long_words = @words |> grep { $_ |> length > 3 }
print "long words: ", @long_words |> join ", ", "\n"
my @lengths = @words |> map { $_ |> length }
print "word lengths: ", @lengths |> join ", ", "\n"