Hello
I wonder.... I'm Java developer and would like to use some "objects" in my application. I have 3 questions that I would be very happy if anyone could help me to explain so I understand.
Lets say I have an object called Person.
In my application I do:
.
use Person; #Defined and is in the same directory as other files...Person.pm
.
.
my $person=Person->new($user,$nr); # $user and $nr unique for current user.
.
.
know I want to store this object in an vector, in java I would have done something like
myvector.addElement(person); # person= $person
and for retrieving my person I would have done
Person p1 =(Person) myvector.getElementAt("position where my object are stored");
I have tried to do like this in Perl but get some errors
push(@myvector,$person);
and
pop(@myvector);
so...
1) How do I store objects in a datastructure like above
2) How can I access the data in this case I would like to go through the hole vector and get all objects of type Person.
3) Lets say I'm using a session handler how do I store/retrieve an Object in a session.
Regarding sessions I have been using:
.
.
use CGI::Session;
my $session = new CGI::Session($sid); #$sid=sessionId
my $usr= $session->param("idkey");
.
.
Thanks in advance!
/MM
I wonder.... I'm Java developer and would like to use some "objects" in my application. I have 3 questions that I would be very happy if anyone could help me to explain so I understand.
Lets say I have an object called Person.
In my application I do:
.
use Person; #Defined and is in the same directory as other files...Person.pm
.
.
my $person=Person->new($user,$nr); # $user and $nr unique for current user.
.
.
know I want to store this object in an vector, in java I would have done something like
myvector.addElement(person); # person= $person
and for retrieving my person I would have done
Person p1 =(Person) myvector.getElementAt("position where my object are stored");
I have tried to do like this in Perl but get some errors
push(@myvector,$person);
and
pop(@myvector);
so...
1) How do I store objects in a datastructure like above
2) How can I access the data in this case I would like to go through the hole vector and get all objects of type Person.
3) Lets say I'm using a session handler how do I store/retrieve an Object in a session.
Regarding sessions I have been using:
.
.
use CGI::Session;
my $session = new CGI::Session($sid); #$sid=sessionId
my $usr= $session->param("idkey");
.
.
Thanks in advance!
/MM