Change 22497 by [EMAIL PROTECTED] on 2004/03/13 21:27:57
Subject: [perl #27567] [patch] a typo and a mistake in perltoot.pod
From: "[EMAIL PROTECTED] (via RT)" <[EMAIL PROTECTED]>
Date: 10 Mar 2004 17:05:09 -0000
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/pod/perltoot.pod#19 edit
Differences ...
==== //depot/perl/pod/perltoot.pod#19 (text) ====
Index: perl/pod/perltoot.pod
--- perl/pod/perltoot.pod#18~22036~ Thu Jan 1 14:23:11 2004
+++ perl/pod/perltoot.pod Sat Mar 13 13:27:57 2004
@@ -1131,9 +1131,9 @@
our $VERSION = '1.1';
-and then in Employee.pm could you can say
+and then in Employee.pm you can say
- use Employee 1.1;
+ use Person 1.1;
And it would make sure that you have at least that version number or
higher available. This is not the same as loading in that exact version
@@ -1497,10 +1497,10 @@
struct 'Fred' => {
one => '$',
many => '@',
- profession => Jobbie, # calls Jobbie->new()
+ profession => 'Jobbie', # does not call Jobbie->new()
};
- $ob = Fred->new;
+ $ob = Fred->new(profession => Jobbie->new());
$ob->one("hmmmm");
$ob->many(0, "here");
@@ -1513,6 +1513,10 @@
You can declare types in the struct to be basic Perl types, or
user-defined types (classes). User types will be initialized by calling
that class's new() method.
+
+Take care that the C<Jobbie> object is not created automatically by the
+C<Fred> class's new() method, so you should specify a C<Jobbie> object
+when you create an instance of C<Fred>.
Here's a real-world example of using struct generation. Let's say you
wanted to override Perl's idea of gethostbyname() and gethostbyaddr() so
End of Patch.