q behaves just like single quotes ' do, but they make it easy to include other single-quotes in a string without the need to escape them.

Immediately after the q you put some opening character and then the string lasts till the ending pair of that character. I usually use some form of a pair of characters (opening and closing curly braces or parentheses), but you can also use other characters as well.

examples/q.pl

use strict;
use warnings;
use 5.010;


my $name = 'Perl';

my $text = 'We have a variable name called \'$name\'.';
say $text;

my $better = q{We have a variable name called '$name'.};
say $better;

my $other = q!We have a variable name called '$name'.!;
say $other;

say q(We have a variable name called '$name'.);
say q[We have a variable name called '$name'.];
say q?We have a variable name called '$name'.?;
say q#We have a variable name called '$name'.#;

The above examples all print the same string:

We have a variable name called '$name'.