Can someone point me to an example of how to implement and access the kind
of object shown below?
Most of the examples if found are an object that contains one other object.
I need to create an object that contains a hash of sub-objects each
sub-object is made up of a number of different objects and an array of an
object type.
Object1 contains scalars
Object2 Contains scalars
Object3 contains scalars (OK that part is easy)
Object4 contains an Object1, an Object2, an array of Object3, and scalars
Object5 contains a hash of Object4 and scalars
Object6 contains a hash of Object5
In general I will get or set each element in each object individually.
The ability to enumerate the object3s in the Object6 and the ability to
Enumerate through the object4s an object5 are the only other complex
accesses I need.
Thanks,
-Pat 5 5771
In article <8_************ ********@adelph ia.com>, John Smith
<so*****@micros oft.com> wrote: Can someone point me to an example of how to implement and access the kind of object shown below?
Most of the examples if found are an object that contains one other object. I need to create an object that contains a hash of sub-objects each sub-object is made up of a number of different objects and an array of an object type.
Object1 contains scalars
Object2 Contains scalars
Object3 contains scalars (OK that part is easy)
Object4 contains an Object1, an Object2, an array of Object3, and scalars
Object5 contains a hash of Object4 and scalars
Object6 contains a hash of Object5
In general I will get or set each element in each object individually.
The ability to enumerate the object3s in the Object6 and the ability to
Enumerate through the object4s an object5 are the only other complex accesses I need.
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
FYI: this newsgroup is defunct; try comp.lang.perl. misc in the future.
Jim Gibson wrote: In article <8_************ ********@adelph ia.com>, John Smith <so*****@micros oft.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>Sa mple.pl
Can't locate object method "speak" via package "Cow" at
C:\Perl\MDGS\Sa mple.pl line 2.
--------------------
Does this mean perl can't recgnize @ISA?
Thanks,
pac
"packat" <ch*****@verizo n.not> schreef in bericht
news:NPY_d.2469 2$hA3.5491@trnd dc09... Jim Gibson wrote: In article <8_************ ********@adelph ia.com>, John Smith <so*****@micros oft.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;
Which Cow, which 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>Sa mple.pl Can't locate object method "speak" via package "Cow" at C:\Perl\MDGS\Sa mple.pl line 2.
--------------------
Does this mean perl can't recgnize @ISA?
Thanks, pac
Move your speaking cow to the point beyond the package declarations and she
will no longer be silent.
Theo van den Heuvel
Theo van den Heuvel wrote: "packat" <ch*****@verizo n.not> schreef in bericht news:NPY_d.2469 2$hA3.5491@trnd dc09... Jim Gibson wrote: In article <8_************ ********@adelph ia.com>, John Smith <so*****@micros oft.com> wrote: Here is my code --------------------
Cow->speak;
Which Cow, which 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>Sa mple.pl Can't locate object method "speak" via package "Cow" at C:\Perl\MDGS\Sa mple.pl line 2.
--------------------
Does this mean perl can't recgnize @ISA?
Thanks, pac
Move your speaking cow to the point beyond the package declarations and she will no longer be silent.
{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!
Theo van den Heuvel
>>>>> "packat" == packat <ch*****@verizo n.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\Sa mple.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken in Melbourne Australia |
last post by:
If I use the curly bracket syntax (referred to as the
complex syntax) within a string, how do I get to call a
function within it?
The php manual says that the first (or previous)
character for the curly bracket has to be a dollar sign '$'.
This is fine for variables, arrays and some objects but
doesn't allow me to call a function such as addslashes() or
trim() before I return the string in the variable.
|
by: Lionel |
last post by:
Hi all,
I would like having more informations on how we could exchange
informations and/or objects between PERL and JAVA.
We have a Java programs that open, maintain and close telnet
connections, for PERL scripts...
Is it possible, to echange the Java telnet session object to PERL
programs ? Or thoses two languages could not exchange objects or such
|
by: spar |
last post by:
I'm converting a Perl script to Python and have run into something I'm
not sure how to do in Python.
In Perl, I am running through a couple loops and inserting values
directly into a complex data structure (array->hash->array). This
isn't the actual code, but should demonstrate the general idea:
foreach $bar_count(@bars) {
foreach $el_count(@els) {
$var = somefunc($bar_count,$el_count);
|
by: Xah Lee |
last post by:
© # -*- coding: utf-8 -*-
© # Python
©
© # in Python, one can define a boxed set
© # of data and functions, which are
© # traditionally known as "class".
©
© # in the following, we define a set of data
© # and functions as a class, and name it xxx
© class xxx:
|
by: Vic Russell |
last post by:
Hi,
I have a soap server running on Linux using SOAP::Lite and it communicates
with a simple perl client on an XP machine and returns a complex perl object
OK. I now want to do the same with a .net VB client and am trying to use
WSDL to get my VB stubs. I have used SOAP::Generate and have successfully
generated a .wsdl file. However, the wsdl.exe ( and wsewsdl2.exe)
applicatuions in .Net are returning all sorts of errors. Before I go to...
| |
by: Sven Neuberg |
last post by:
Hi,
I have been handed the task of updating and maintaining a web
application, written in ASP and Javascript, that takes complex
user inputs in HTML form and submits them to server-side ASP
pages for processing. The problem is, the user inputs can
become very complex, and the way this application was developed,
the inputs are all concatenated into monstrously long strings
of text that are then submited as <hidden> inputs in HTML forms...
|
by: Trail Monster |
last post by:
Ok, I've been searching the net now for several days and can't find how to do
this anywhere.
Version:
VS 2005 Professional Release, 2.0 Framework
Background:
I have a complex business object Employee that contains public properties
and several nested objects such as a Spouse object and a List of Coverage
objects.
|
by: =?Utf-8?B?ZHNoZW1lc2g=?= |
last post by:
Hello,
My problem is a little complex... Here it goes:
I have a web service in my system which my users need to web reference. By
web referencing my web service, my users can use all kinds of complex objects
which were defined by myself (including inheritance) .
Next, I want my customers to publish a wsdl predefined by myself so I can
call their methods. This predefined wsdl contains a few methods which receive
and return the objects I...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |