Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Perl String Scalars



The following example demonstrates the usage of various types of string scalars. Notice the difference between single-quoted strings and double-quoted strings −

Example

 Live Demo

#!/usr/bin/perl
$var = "This is string scalar!";
$quote = 'I m inside single quote - $var';
$double = "This is inside single quote - $var";
$escape = "This example of escape -\tHello, World!";

print "var = $var\n";
print "quote = $quote\n";
print "double = $double\n";
print "escape = $escape\n";

Output

This will produce the following result −

var = This is string scalar!
quote = I m inside single quote - $var
double = This is inside single quote - This is string scalar!
escape = This example of escape -       Hello, World
Updated on: 2019-11-28T08:19:14+05:30

271 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements