

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Single and Double Quotes in Perl
You can use double quotes or single quotes around literal strings as follows −
Example
#!/usr/bin/perl print "Hello, world\n"; print 'Hello, world\n';
Output
This will produce the following result −
Hello, world Hello, world\n$
There is an important difference between single and double-quotes. Only double quotes interpolate variables and special characters such as newlines \n, whereas a single quote does not interpolate any variable or special character. Check below example where we are using $a as a variable to store a value and later printing that value −
Example
#!/usr/bin/perl $a = 10; print "Value of a = $a\n"; print 'Value of a = $a\n';
Output
This will produce the following result −
Value of a = 10 Value of a = $a\n$
- Related Questions & Answers
- Single quotes vs. double quotes in C or C++
- What is the difference between single and double quotes in python?
- What is the difference between single and double quotes in JavaScript?
- Is there a PHP function that only adds slashes to double quotes NOT single quotes
- Print newline in PHP in single quotes
- Find records with double quotes in a MySQL column?
- How to insert records with double quotes in MySQL?
- How to escape single quotes in MySQL?
- How to print double quotes with the string variable in Python?
- Difference between Single-Cage and Double-Cage Induction Motors
- Java Program to display double and single quote in a string
- Difference between single quote (‘) and double quote (“) in PowerShell?
- Escaping/encoding single quotes in JSON encoded HTML5 data attributes
- Using MySQL keywords in a query surrounded with single quotes?
- Using single quotes around database and table name isn’t working in MySQL?
Advertisements