Previous Page Next Page

4.6. What's Next?

In the next chapter, you will learn about Perl variables and the meaning of the "funny symbols." You will be able to create and access scalars, arrays, and hashes understand context and namespaces. You will also learn how to get input from a user and why we need to "chomp." A number of array and hash functions will be introduced.

Exercise 4: A String of Perls

1.Use the print function to output the following string:

"Ouch," cried Mrs. O'Neil, "You musn't do that Mr. O'Neil!"

2.Use the printf function to print the number $34.6666666 as $34.67.
3.Write a Perl script called literals.plx that will print the following:
$ perl literals
Today is Mon Mar 12 12:58:04 PDT 2007 (Use localtime())
The name of this PERL SCRIPT is literals.
Hello. The number we will examine is 125.5.
The NUMBER in decimal is 125.
The following number is taking up 20 spaces and is right justified.
|                        125|
                The number in hex is 7d
                The number in octal is 175
The number in scientific notation is 1.255000e+02
The unformatted number is 125.500000
The formatted number is 125.50
My boss just said, "Can't you loan me $12.50 for my lunch?"
I flatly said, "No way!"
Good-bye (Makes a beep sound)

Note: The words PERL SCRIPT and NUMBER are capitalized by using string literal escape sequences.

What command-line option would you use to check the syntax of your script?

4.Add to your literals script a here document to print:

Life is good with Perl.

I have just completed my second exercise!

5.How would you turn on warnings in the script? How would you turn on diagnostics?


 

Previous Page Next Page