X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlbot.pod;h=bc4e4da1f7756e8b275f1fbc08ece2f373f5d643;hb=5ad8ef521b3ffc4e6bbbb9941bc4940d442b56b2;hp=e4952661b0b76e5910aa08c1c6e5f93a25e5ed20;hpb=697934ef381c2fbd2ff49c5e4b22e596a509b7a0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlbot.pod b/pod/perlbot.pod index e495266..bc4e4da 100644 --- a/pod/perlbot.pod +++ b/pod/perlbot.pod @@ -104,14 +104,14 @@ variables. Named parameters are also demonstrated. package main; - $x = Foo->new( 'High' => 42, 'Low' => 11 ); - print "High=$x->{'High'}\n"; - print "Low=$x->{'Low'}\n"; - - $y = Bar->new( 'Left' => 78, 'Right' => 40 ); - print "Left=$y->[0]\n"; - print "Right=$y->[1]\n"; - + $a = Foo->new( 'High' => 42, 'Low' => 11 ); + print "High=$a->{'High'}\n"; + print "Low=$a->{'Low'}\n"; + + $b = Bar->new( 'Left' => 78, 'Right' => 40 ); + print "Left=$b->[0]\n"; + print "Right=$b->[1]\n"; + =head1 SCALAR INSTANCE VARIABLES An anonymous scalar can be used when only one instance variable is needed. @@ -127,8 +127,8 @@ An anonymous scalar can be used when only one instance variable is needed. package main; - $x = Foo->new( 42 ); - print "a=$$x\n"; + $a = Foo->new( 42 ); + print "a=$$a\n"; =head1 INSTANCE VARIABLE INHERITANCE @@ -159,9 +159,9 @@ object. package main; - $x = Foo->new; - print "buz = ", $x->{'buz'}, "\n"; - print "biz = ", $x->{'biz'}, "\n"; + $a = Foo->new; + print "buz = ", $a->{'buz'}, "\n"; + print "biz = ", $a->{'biz'}, "\n"; @@ -191,9 +191,9 @@ relationships between objects. package main; - $x = Foo->new; - print "buz = ", $x->{'Bar'}->{'buz'}, "\n"; - print "biz = ", $x->{'biz'}, "\n"; + $a = Foo->new; + print "buz = ", $a->{'Bar'}->{'buz'}, "\n"; + print "biz = ", $a->{'biz'}, "\n"; @@ -314,8 +314,8 @@ that it is impossible to override the BAZ() method. package main; - $x = FOO->new; - $x->bar; + $a = FOO->new; + $a->bar; Now we try to override the BAZ() method. We would like FOO::bar() to call GOOP::BAZ(), but this cannot happen because FOO::bar() explicitly calls @@ -351,8 +351,8 @@ FOO::private::BAZ(). package main; - $x = GOOP->new; - $x->bar; + $a = GOOP->new; + $a->bar; To create reusable code we must modify class FOO, flattening class FOO::private. The next example shows a reusable class FOO which allows the @@ -386,8 +386,8 @@ method GOOP::BAZ() to be used in place of FOO::BAZ(). package main; - $x = GOOP->new; - $x->bar; + $a = GOOP->new; + $a->bar; =head1 CLASS CONTEXT AND THE OBJECT @@ -444,10 +444,10 @@ method where that data is located. package main; - $x = Bar->new; - $y = Foo->new; - $x->enter; - $y->enter; + $a = Bar->new; + $b = Foo->new; + $a->enter; + $b->enter; =head1 INHERITING A CONSTRUCTOR @@ -476,8 +476,8 @@ object will be a BAR not a FOO, even though the constructor is in class FOO. package main; - $x = BAR->new; - $x->baz; + $a = BAR->new; + $a->baz; =head1 DELEGATION