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.3 Examples of Invalid Single-quoted Strings

In finishing our discussion of singled-quoted strings, consider these examples of strings that are not legal because they violate the exceptions we talked about above:

'You cannot do this: \'; # INVALID: the ending \ cannot be alone 'It is 5 o'clock!' # INVALID: the ' in o'clock should be escaped 'Three \'s: \\\\\'; # INVALID: the final \ escapes the ', thus # the literal is not terminated 'This is my string; # INVALID: missing close quote

Sometimes, when you have invalid string literals such as in the example above, the error message that Perl gives is not particularly intuitive. However, when you see error messages such as:

(Might be a runaway multi-line '' string starting on line X) Bareword found where operator expected Bareword "foo" not allowed while "strict subs" in use

It is often an indication that you have runaway or invalid strings. Keep an eye out for these problems. Chances are, you will forget and violate one of the rules for single-quoted strings eventually, and then need to determine why you are unable to run your Perl program.




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