Node:Examples of Interpolation, Next:, Previous:Interpolation in Double-quoted Strings, Up:Double-quoted Strings



Examples of Interpolation

Let us consider an example that uses a few of these characters:

     #!/usr/bin/perl
     
     use strict;
     use warnings;
     
     print "A backslash: \\\n";
     print "Tab follows:\tover here\n";
     print "Ring! \a\n";
     print "Please pay bkuhn\@ebb.org \$20.\n";
     

This program, when run, produces the following output on the screen:

     A backslash: \
     Tab follows:	over here
     Ring!
     Please pay bkuhn@ebb.org $20.
     

In addition, when running, you should hear the computer beep. That is the output of the \a character, which you cannot see on the screen. However, you should be able to hear it.

Notice that the \n character ends a line. \n should always be used to end a line. Those students familiar with the C language will be used to using this sequence to mean newline. When writing Perl, the word newline and the \n character are roughly synonymous.