Do you have to end packages with any type of notation or command? I have
written a module file with two packages in it, but I am having a hell of a
time with miss-referenced or no reference vars in the file. Thanks,
-Nick
_
Get your
Here is a basic attribute definition from an O'Reilly Book:
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
color => "bay",
legs => 4,
@_ ,
};
return bless $self
Does the C++ notion of private data have a similar structure in perl, when
defining packages, I find that when I try to define global variables inside
the package, but outside of all the subroutines, I get a million errors.
Thanks,
-Nick
Assuming I am defining an object which has as its only property a level
associated with it, would these be the correct simple subroutines to
retrieve and set that property. Also, is this the correct usage of the @_
array such that the level value would be 999 unless I called new(Level =>
somet
Given this function to create a new class object:
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
Level => 999, #values Value => 999,
Key => 999,
@Next,
given this new function which acts as a constructor
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
Level => 999,
Value => 999,
Key => 999,
@Next,
@_,
the var?
>From: Chas Owens <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: more class stuff
>Date: 18 Jun 2001 17:57:14 -0400
>
>On 18 Jun 2001 16:42:45 -0500, Nick Transier wrote:
> > given this new function which acts as a constructor
> >
> &
Given that I am trying to define an object attribute which is an array of
references to other object of the same type, how do I define this in the
$self portion of my sub new constructor? This is what I have, will this
work? Next is meant to hold an array of pointers or references.
sub new {
The thing is, I want to set the array reference later and not when the
object is being created.
>From: [EMAIL PROTECTED] (Randal L. Schwartz)
>To: "Nick Transier" <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: Self Def
>Date: 19 Jun 2001 14:12:13
If I define a function just in the freespace of a file and have included in
that file two packages which are bracketed in like:
sub function {}
package 1;
{}
package 2;
{}
How do I access the function (make a function call) from within one of the
packages?
is it main::function or is it so
Given this is my definition for self in some new constructor:
sub new {
$self {
Next => @[Max_Level],
}
}
First, is this the proper way to have Next be a reference to an annonymous
array of size Max_Level?
More importantly, how do you reference the elements in the a
I have two different packages that access each others methods. (where in my
case one package is an element I have defined and the other package is an
implementation of a list of those elements) When I call a method from
package 1 with an object from package 2. the method in package 1 takes a
$
So then would I access the nth element by
@{$self->{Next}}[n] ??
>From: [EMAIL PROTECTED] (Randal L. Schwartz)
>To: "Nick Transier" <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: $self def
>Date: 20 Jun 2001 09:29:41 -0700
>
> >>>>
You are saying I cannot set the size of an array? I understand that you do
not have to, but I need to in this case so that my iteration loops work
correctly.
>From: John Edwards <[EMAIL PROTECTED]>
>To: 'Nick Transier' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
>Su
I have written a module I want to test in a shell program, how do I load the
module in another perl file to test the methods of the module's packages?
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com
Ok, I have a package
package blah;
{
sub foo {
print "I do not understand perl"
return 5;
}
}
Now, how do I call this function from outside the package?
I have written this:
$perlversion = blah::->foo;
but it doesn't work, it asks for explicit package name.
Please help.
-Nick
I tried that, same error. "$perlversion requires explicit package name"
>From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: Nick Transier <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: method calls outside the
I have written some OO perl and I have a problem that I just realized, when
you set an object = to another object, they become irreversibly linked and
all operations on one or the other causes changes in both. If I am trying to
simply initialize the object and not link them, how do I get around
Isn't == a logical operator? I am not trying to compare the two objects.
>From: "Sally" <[EMAIL PROTECTED]>
>To: "Nick Transier" <[EMAIL PROTECTED]>
>Subject: RE: =
>Date: Thu, 21 Jun 2001 17:18:47 +0100
>
>You should use == instead
Ok, so I see the way around the = problem with cloning, however, there is a
clone module on CPAN, but I have no idea how to install it using win2k. Any
ideas?
Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explore
Ok,
I am running windows 2000, I have perl, but I do not know which
distribution, I do not think that it is activestate's however. I searched by
drive and found ppm in a folder in the perl folder, but there is no
executable and I do not know how to run it at the dos command line. I have
do
Ok, so I was wrong, I do have ppm, but I have "installed" the package but it
doesn't work. I installed the clone package available from Activstate, but
when I say "use clone" in my program, it says the files are missing. What is
this all about?
-Nick
___
If I am generating a random number with the rand function, how can I
truncate the resulting var to an integer?
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com
Does anyone know a way to make boolean comparisons between strings?
For example, I want 'a' < 'b' to be true, but perl says 'a' == 'b' is true.
Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com
If I define a variable as a string
my $var = "a";
I can get the increment to work
print ++$var; --> prints b
but the decrement
print --$var --> prints -1
Why? and how can I decrement it?
Thanks,
-Nick
_
Get your FREE download of
25 matches
Mail list logo