Home arrow Perl Programming arrow Page 3 - Beginning Programming Perl(s)

Quoth the Raven - Perl

In the last article, you learned how to install Perl. It wouldn't make a lot of sense to install it on your computer if you never did anything with it, now would it? In this article, you'll take your first steps to becoming part of a wild and crazy breed -- a Perl programmer.

  1. Beginning Programming Perl(s)
  2. Storing Data in A Variable
  3. Quoth the Raven
  4. List Data Types
By: James Payne
Rating: starstarstarstarstar / 9
October 10, 2007

print this article



In the above example we worked with a string, or a group of characters. We encased it in single quotes ('), which lets the program know where the string ends and begins. Which is fine and dandy. But what if you come across a contraction? If you try the following code you will get strange results:


$my_sentence = 'I simply can't do it!';

print "$my_sentencen";

Because there is a single quote(') in the contraction can't, the program sees the word can as the end of the string, instead of the word it with an exclamation mark, as we originally intended. To fix this, you escape the quote with the backslash() key.



$my_sentence = 'I simply can't do it!';

print "$my_sentencen";

To use special characters like the n or to print a variable, we use the double quotes("). Consider the following:


$my_sentence = 'I simply can't do it!';

print "$my_sentencen";

print '$my_sentencen';

In the above code, the following would print out:

  I simply can't do it!


See? You need the double quotes for those special keys, otherwise they will be seen as a normal string of text.

>>> More Perl Programming Articles          >>> More By James Payne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates


Dev Shed Tutorial Topics: