-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use v6; | ||
|
||
=begin pod | ||
=TITLE Reversing a String by Word or Character | ||
=AUTHOR stmuk | ||
You want to reverse words or characters in a string | ||
=end pod | ||
|
||
my $string = "The Magic Words are Squeamish Ossifrage"; | ||
|
||
# reverse the characters in a scalar | ||
|
||
say $string.flip; | ||
|
||
# reverse the words in a scalar | ||
|
||
say $string.split(" ").reverse; | ||
|
||
# vim: expandtab shiftwidth=4 ft=perl6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use v6; | ||
|
||
=begin pod | ||
=TITLE Trimming whitespace from both ends of a string | ||
=AUTHOR stmuk | ||
You have a string with leading and/or trailing whitespace | ||
you wish to remove | ||
=end pod | ||
|
||
my $string = "\t the cat sat on the mat "; | ||
|
||
$string.=trim; | ||
|
||
say :$string.perl; | ||
|
||
# vim: expandtab shiftwidth=4 ft=perl6 |