Re: Complex Objects in Perl
From: packat (chariya_at_verizon.not)
Date: 03/19/05
- Next message: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Previous message: iorcc_at_yahoo.com: "ANN: 2005 International Obfuscated Ruby Code Contest (IORCC)"
- Next in thread: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Reply: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 19 Mar 2005 16:55:09 GMT
Jim Gibson wrote:
> In article <8_ydnS49C86x9S3cRVn-tA@adelphia.com>, John
> Smith
> <someone@microsoft.com> wrote:
>
> Objects in Perl are implemented as a reference to an
> anonymous hash.
> The keys to the hash are the names of the members, and the
> values of
> the hash may be any scalar. This includes normal scalar
> values and
> references. Thus, a member of your object may be a
> reference to an
> array or a hash or it may be another object (reference to
> a hash) or a
> method (reference to subroutine). So you can have any
> level of nesting
> of objects-within-objects and arrays or hashes of other
> objects. You
> enumerate over array and hash members as you would
> enumerate over any
> array or hash given a reference to one of these.
>
> See the following documentation built into your
> installation of perl:
>
> 'perldoc perlreftut' Perl references tutorial
> 'perldoc perldsc' Perl data structures cookbook
> 'perldoc perllol' Manipulating arrays of arrays in
> Perl
> 'perldoc perlboot' Beginner's object-oriented
> tutorial
>
Thanks for the info. I have been using perl on and off but
never tried its OO feature.
I followed the example in perlcod perlboot but got an error.
Here is my code
--------------------
Cow->speak;
{ package Animal;
sub speak {
my $class = shift;
print "a $class goes ",$class->sound,"!\n";
}
}
{ package Cow;
use vars qw(@ISA);
@ISA = qw(Animal);
print "Hi >$ISA[0]>\n";
sub sound {"Mooo"}
}
---------------------
After execution, I got
C:\Perl\MDGS>
C:\Perl\MDGS>
C:\Perl\MDGS>Sample.pl
Can't locate object method "speak" via package "Cow" at
C:\Perl\MDGS\Sample.pl line 2.
--------------------
Does this mean perl can't recgnize @ISA?
Thanks,
pac
- Next message: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Previous message: iorcc_at_yahoo.com: "ANN: 2005 International Obfuscated Ruby Code Contest (IORCC)"
- Next in thread: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Reply: Theo van den Heuvel: "Re: Complex Objects in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|