Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1.1 Single-quoted Strings

String literals can be represented in primarily three ways in Perl. The first way is in single quotes. Single quotes can be used to make sure that nearly all special characters that might be interpreted differently are taken at "face value". If that concept is confusing to you, just think about single quoted strings as being, for the most part, "what you see is what you get". Consider the following single-quoted string:

'i\o'; # The string 'i\o'

This represents a string consisting of the character `i', followed by `\', followed by `o'. However, it is probably easier just to think of the string as @string{i\o}. Some other languages require you think of strings not as single chunks of data, but as some aggregation of a set of characters. Perl does not work this way. A string is a simple, single unit that can be as long as you would like.(2)

Note in our example above that 'i\o' is an expression. Like all expressions, it evaluates to something. In this case, it evaluates to the string value, i\o. Note that we made the expression 'i\o' into a statement, by putting a semi-colon at the end ('i\o';). This particular statement does not actually perform any action in Perl, but it is still a valid Perl statement nonetheless.

2.1.1.1 Special Characters in Single-quoted Strings  
2.1.1.2 Newlines in Single-quoted Strings  
2.1.1.3 Examples of Invalid Single-quoted Strings  




 
 
  Published under the terms of the GNU General Public License Design by Interspire