Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active April 18, 2016 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/669dbab640ad74ec98ce3451a17428e8 to your computer and use it in GitHub Desktop.
Save dogbert17/669dbab640ad74ec98ce3451a17428e8 to your computer and use it in GitHub Desktop.
Newbie attempt at creating documentation for the samecase method. Some inspiration from http://search.cpan.org/~moritz/Perl6-Str-v0.0.5/lib/Perl6/Str.pm
=head2 routine samecase
Defined as:
sub samecase(Cool $string, Cool $pattern)
method samecase(Cool:D: Cool $pattern)
Usage:
samecase STRING, PATTERN
STRING.samecase(PATTERN)
Coerces the invocant (or in sub form, the first argument) to L<Str|/type/Str>, and returns a
copy of $string with case information for each individual character changed according to $pattern.
(The pattern string can contain three types of characters, i.e. uppercase, lowercase and caseless.
For a given character in $pattern its case information determines the case of the corresponding
character in the result.)
If $string is longer than $pattern, the case information from the last character of
$pattern is applied to the remaining characters of $string.
say "perL 6".samecase("A__a__"); # Perl 6
say "pERL 6".samecase("Ab"); # Perl 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment