Skip to content

Strings in Perl 6

Charlie Gonzalez edited this page Feb 6, 2016 · 12 revisions

Basic information about strings

  1. How are strings stored in P6?

Strings are stored in a Scalar and are enclosed in single or double quotes.

my $name = 'John Doe';
my $name2 = "James Doe";

say $name;
say $name2;

Output:

$
John Doe
James Doe
  1. What are some functions available for strings?

*uc will uppercase all characters in a string. *chars will return the number of characters in string. *flip will return the same string in reverse.

my $name = 'John Doe';

say $name.uc;
say $name.chars;
say $name.flip;

Output:

$
JOHN DOE
8
eoD nhoJ

Clone this wiki locally