Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Complex Objects in Perl
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
packat  
View profile  
 More options Mar 19 2005, 11:55 am
Newsgroups: comp.lang.perl
From: "packat" <char...@verizon.not>
Date: Sat, 19 Mar 2005 16:55:09 GMT
Local: Sat, Mar 19 2005 11:55 am
Subject: Re: Complex Objects in Perl

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Theo van den Heuvel  
View profile  
 More options Mar 20 2005, 3:40 am
Newsgroups: comp.lang.perl
From: "Theo van den Heuvel" <vdh...@kabelfoon.nl>
Date: Sun, 20 Mar 2005 09:40:19 +0100
Local: Sun, Mar 20 2005 3:40 am
Subject: Re: Complex Objects in Perl
"packat" <char...@verizon.not> schreef in bericht
news:NPY_d.24692$hA3.5491@trnddc09...

Which Cow, which speak?

Move your speaking cow to the point beyond the package declarations and she
will no longer be silent.

Theo van den Heuvel


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
packat  
View profile  
 More options Mar 20 2005, 7:15 am
Newsgroups: comp.lang.perl
From: "packat" <char...@verizon.not>
Date: Sun, 20 Mar 2005 12:15:21 GMT
Local: Sun, Mar 20 2005 7:15 am
Subject: Re: Complex Objects in Perl
Theo van den Heuvel wrote:

{package packat;
sub sound {"Duh!"}

}

I just follow the sample code in perldoc without reordering
the sequesce....
It works fine now.  Hmmm..  I have a great projct for it.

Thnaks for you help,
pac
packar->
Duh!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac To  
View profile  
 More options Mar 20 2005, 8:39 am
Newsgroups: comp.lang.perl
From: Isaac To <ike...@netscape.net>
Date: 20 Mar 2005 21:39:29 +0800
Local: Sun, Mar 20 2005 8:39 am
Subject: Re: Complex Objects in Perl

>>>>> "packat" == packat  <char...@verizon.not> writes:

    packat> Cow-> speak;
    packat> { package Animal;
    packat>   sub speak {
    packat>       my $class = shift;
    packat>       print "a $class goes ", $class->sound, "!\n";
    packat>   }
    packat> }
    packat> { package Cow;
    packat>   use vars qw(@ISA);
    packat>   @ISA = qw(Animal);
    packat>   print "Hi >$ISA[0]>\n";
    packat>   sub sound {"Mooo"}
    packat> }

    packat> After execution, I got
    packat> Sample.pl Can't locate object method "speak" via package
    packat> "Cow" at C:\Perl\MDGS\Sample.pl line 2.

    packat> Does this mean perl can't recgnize @ISA?

It means you've put the "Cow->speak" too early, before Perl execute
the statements that assigns @Cow::ISA.  Try putting it into the last
statement, and remember that Perl execute each file in your program
line by line (except that subroutines are defined before anything is
executed, together with the things you put in BEGIN {}, includes by
"use", etc).

Regards,
Isaac.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google