2009/11/12 Jason Lowder <[email protected]>

> 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;
>

If you name your package "functions", is it really an object class ?


> ...
> sub createPositionData {
>     my ($self, @posData) = @_;
>

Remove the '@' in the object member name in the following lines. Or use
quotes around your member name ($self->{'@_positionData'} if that is really
how you want it to be named.

    $self->{...@_positiondata} = @posData if defined(@posData);
>     return $self->{...@_positiondata};
> }
>
>
I suspect you are not in strict mode (use strict; use warnings;). You would
see an error about an undefined variable @_positionData if you were.




> The if defined line also
> complains about being deprecated so clearly there is another means of
> doing this.
>
You should replace "if defined(@posData)" with "if @posData". @posData in
scalar context is evaluated as the number of its elements, so the condition
will apply if @posData has at least one element.

Olivier Mengué.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to