Workshop

Quiz

1:Variables are interpolated inside qq quotes.
  1. True

  2. False

2:What value is stored in $c after running the following code?
$a=6;
$a++;
$b=$a;
$b−−;
$c=$b;
  1. 6

  2. 7

  3. 8

3:Concatenation can be performed only with the concatenation operator (.).
  1. True

  2. False

Answers

A1: a. qq behaves in every way like a pair of double quotation marks. This means it can interpolate variables.
A2: a. $a is set to 6. $a is then incremented to 7, and assigned to $b. $b is decremented to 6, and assigned to $c.
A3: b. Remember from Hour 1, in Perl, There Is More Than One Way To Do It (TIMTOWTDI). Concatenation can be performed by including two (or more) scalars in a double-quoted string, as follows:
qq($a$b$c);

Activities

  • Write a short program that prompts the user for ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.