Jason Lowder <> wrote:
> Hi,
>
> I'm trying to make my perl source as OO as possible (fairly new to
> it) and while I can set values in set methods, I can't seem to figure
> out how to set arrays or hashes this way.
>
> My code:
>
> package SQLfunctions;
> ...
> sub createPositionData {
> my ($self, @posData) = @_;
> $self->{...@_positiondata} = @posData if defined(@posData);
> return $self->{...@_positiondata};
> }
Assuming that you object is a blessed hash ref. The code to store an
array in it might look something like:
sub createPositionData {
my ($self, @posData) = @_;
$self->{posData} = \...@posdata if @posData > 0;
if (wantarray) {
return @{$self->{posData}};
}
else {
return $self->{posData};
}
}
>
> 1;
>
> our $mySQL = SQLfunctions->new;
> $mySQL->createPositionData(1,2,3,4,5);
>
>
> I've tried other variations with no luck. The if defined line also
> complains about being deprecated so clearly there is another means of
> doing this. I have plenty of methods like this for single value
> variables, but can't find examples of how to pass arrays or hash
> values.
>
> Any suggestions?
Read the documentation on OO that comes with Perl (perldoc perl$_
foreach qw{boot toot tooc bot}). Also Damian Conway's book comes highly
recommended. I can't remember toe title off-hand, but you can google for
it.
For things like storing arrays in hashes, 'perldoc perldsc' would be
useful.
HTH
--
Brian Raven
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs