- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl Quote-like Operators Example
There are following Quote-like operators supported by Perl language. In the following table, a {} represents any pair of delimiters you choose.
Sr.No. | Operator & Description |
---|---|
1 | q{ } Encloses a string with-in single quotes Example − q{abcd} gives 'abcd' |
2 | qq{ } Encloses a string with-in double quotes Example − qq{abcd} gives "abcd" |
3 | qx{ } Encloses a string with-in invert quotes Example − qx{abcd} gives `abcd` |
Example
Try the following example to understand all the quote-like operators available in Perl. Copy and paste the following Perl program in test.pl file and execute this program.
#!/usr/local/bin/perl $a = 10; $b = q{a = $a}; print "Value of q{a = \$a} = $b\n"; $b = qq{a = $a}; print "Value of qq{a = \$a} = $b\n"; # unix command execution $t = qx{date}; print "Value of qx{date} = $t\n";
When the above code is executed, it produces the following result −
Value of q{a = $a} = a = $a Value of qq{a = $a} = a = 10 Value of qx{date} = Thu Feb 14 08:13:17 MST 2013
perl_operators.htm
Advertisements