Lesson 4 of 15
Strings
Working with Strings
Perl has two kinds of string literals:
Double-Quoted Strings
Double-quoted strings interpolate variables and escape sequences:
my $name = "World";
say "Hello, $name!"; # Hello, World!
say "Tab:\there"; # Tab: here
say "Newline:\n"; # prints a newline
Single-Quoted Strings
Single-quoted strings are literal -- no interpolation:
say 'Hello, $name!'; # Hello, $name! (literally)
String Concatenation
The dot . operator concatenates strings:
my $full = "Hello" . ", " . "World!";
say $full; # Hello, World!
String Repetition
The x operator repeats a string:
say "ha" x 3; # hahaha
String Functions
say uc("hello"); # HELLO
say lc("HELLO"); # hello
say length("Perl"); # 4
Your Task
Create two variables $first and $last, concatenate them with a space, and print the full name.
JS Transpiler loading...
Loading...
Click "Run" to execute your code.