[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] Object Oriented Perl question
* Stephen J. Turnbull (turnbull [at] sk.tsukuba.ac.jp) wrote:
> >>>>> "Richard" == Richard Lowe <richlowe [at] btinternet.com> writes:
>
> Richard> Can anyone point me at any documentation that explains
> Richard> how to use an object, with an array of objects in it.
>
> After looking at perlobj(1p) and perltoot(1p), my immediate reaction
> is "`info python-tut' is your friend." That's probably not very
> helpful.[1]
I prefer Perl for some reason, must be masochism :)
> Richard> so i end up with a call like
>
> Richard> $blum->bar()[1]->name("fred");
>
> Break it up into temp variables
>
> @t = $blum->bar()
> $u = $t[1]
> $u->name("fred")
>
Now this confuses me, in the fact that I would end up with an object
as i wanted, but it would no longer be in ther array,
The problem (apart from the syntax being wrong), was that the elements
in the array weren't being bless()'d into the class (for reasons i dont
fully understand).
I managed to get hold of a friend on IRC, who suggested pre-creating the
array instead of creating individual objects and push()'ing them on.
and thats working.
thanks for the help.
> Footnotes:
> [1] It does explain why the various deb{conf,helper,...} packages are
> so buggy. You can't tell the difference between Perl code and random
> strings without running it.
>
I find perl far easier to understand than something like scheme.
But I've always found C more logical, (if i declare somthing as an int i
like it to stay that way, not decide its a string when i least expect it
:)).
--
|*-------------------=[ Richard Lowe ]=------------------*|
| richlowe [at] btinternet.com UIN: 74724348 |
|*-------------------------------------------------------*|
| Europe has the Kilogram and the Meter. |
| America has the Pound and the Inch. |
| Childrens TV has the Elephant and the Double Decker Bus |
|*-------------------------------------------------------*|
---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word
"unsubscribe" in the body of the message.
GNU the choice of a complete generation.