head 1.2;
access;
symbols;
locks
mjd:1.2; strict;
comment @# @;
1.2
date 99.06.08.04.05.56; author mjd; state Exp;
branches;
next 1.1;
1.1
date 99.06.08.03.54.50; author mjd; state Exp;
branches;
next ;
desc
@@
1.2
log
@Reorganized exercise 4 to introduce indirect object notation first
because the way it passes the arguments is more straightforward.
@
text
@
Exercises: Do these in order. Do all of them. I promise not to
waste your time.
0. There should be a directory named `Module' next to this one.
Do all the exercises there first. Then come back here.
1. Read the code in hello.pl and Hello.pm and try it out. Run
hello.pl and see what happens.
2. Look at the error message that the sample program produces.
Change the `croak' to `die' in `Hello.pm' and see how the error
message changes. What is the difference? When might you prefer
`croak' to `die'?
3. What are the arguments to the `new' function?
Put a line into `new' that prints out the argument list.
In `hello.pl', change the call to `new' to say
new Hello ("Buenos Dias");
What are the arguments now?
Now change the call to say
Hello->new("Guten Tag");
What are the arguments now?
4. Change `new' to accept an optional arument which is used as an
initial message for the greeting object. If the optinal argument
is missing, the function should use "Hello, world" as it does at
present. Write a test program for this new feature.
5. What are the arguments to the `setmessage' function? Put a line
into `setmessage' that prints out the argument list. Notice
especially what `$self' looks like when you print it out.
6. Change `new' to set up a DEFAULT field instead of a MESSAGE field
in the new object, and then fix `greet' to use the MESSAGE field if
there is one, and the DEFAULT field otherwise.
Then modify `setmessage' to make the argument optional. If the
argument is omitted, then instead of croaking, it should reset the
message to the default. Write a test program for this new feature.
7. Change the name of the module from `Hello' to `Greeting'. Change
the test program to use the new module.
8. Write to me with a suggestion about the notes or exercises could be
improved.
mjd-perl-modtut@@plover.com
@
1.1
log
@Initial revision
@
text
@d20 7
a26 1
Hello->new("Buenos Dias");
@