All the special characters or symbols like @, #, $, & /, \, etc does not print in a normal way. They need a preceding escaping character backward slash (\) to get printed.
All the e-mail addresses contain (@) sign. As stated earlier, symbols will not be printed normally inside a string. They need extra attention. Use backward slash (\) before @ sign to print e-mail addresses.
use strict; use warnings; my $site = "rookienerd\@gmail.com"; print "$site\n";
If we want to print ($) sign inside a string, use backward slash (\) preceding $ sign.
use strict; use warnings; my $msg1 = 'Ana'; print "We have defined \$msg1 as $msg1\n";
If we want to print (\) sign inside a string, use backward slash (\) preceding \ sign.
use strict; use warnings; print "The \\n is a new line chracter in programming languages.\n";
If you want to print double quotes inside a string use backslash (\) at both the quotes.
use strict; use warnings; my $x = 'tutorials'; print "Our site \"rookienerd\" provides all type of \"$x\"\n";
The "qq" operator replaces the double quote surrounding a string by its parentheses. It means ("") are not essential on this string anymore. It will simply print the string with qq.
But if you want a bracket inside a string then you need to use curly braces {} surrounding the string.
And if you need curly braces inside the string then use square bracket [] surrounding the string.
#use of qq use strict; use warnings; my $x = 'tutorials'; print qq(Our site "rookienerd" provides all type of "$x"\n); #use of {} brackets print qq{Our site (rookienerd) provides all type of "$x"\n}; #use of [] brackets print qq[Our site (rookienerd} provides all type of "$x"\n];
The single 'q' operator works as the single quote (') in the string. Like single quote, it also does not interpolate the variables.
#use of q use strict; use warnings; my $x = 'tutorials'; print q(Our site "rookienerd" provides all type of "$x"\n); print"\n"; #use of () brackets print q(Our site "rookienerd" provides all type of "$x"\n); print"\n"; #use of {} brackets print q{Our site )rookienerd( provides all type of "$x"\n}; print"\n"; #use of {} brackets print q[Our site )rookienerd} provides all type of "$x"\n];