Everyday Computing Advanced Computing The Internet At Home Health, Mind & Body Making & Managing Money Sports & Leisure Travel Beyond The Classroom
Certification
Databases
Networking
Programming
Perl For Dummies , 4th Edition

Understanding Perl Strings


Adapted From: Perl For Dummies , 4th Edition

Text items in Perl are called strings. A string is zero or more characters put together in a single chunk. A character is anything that you can type, such as letters, digits, punctuation, and spaces. Strings appear in variables and just as themselves, in which case they are called string literals. An example of a one-character string literal is the letter d. An example of a five-character string is vbn59. Perl variables can hold strings or numbers.

The length of a Perl string is practically unlimited. That's right, you can make Perl strings as long as you want. Then again, you don't have to give them any length at all. A zero-character string is as a null string. "A textless string, that's odd!" you say? Here's how that works:

If you have a variable called $Short, for example, and that variable has a value that is one character, you can remove the single character from the variable and get a smaller value that has zero characters in it. The variable doesn't disappear because Perl knows to how remove characters while retaining the variable. Similarly, if you want to add to a variable character by character, you can start with no characters and build from there.

Related Articles
Contrasting Single and Double Quotes in Perl
Avoiding Common Oversights in Perl
Examining Perl's Pluses for Programming
Understanding Objects and the Oracle9i Database
Tuning Into Ten Short, Useful Perl Programs
Related Titles
SQL For Dummies, 6th Edition
Microsoft SQL Server 2005 Programming For Dummies
Visual C++6 For Dummies
Perl For Dummies , 4th Edition
Apache, MySQL, and PHP Web Development All-in-One Desk Reference For Dummies