Click here to get back home

OO Perl Online Learning

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
OO Perl Online Learning Xiong Changnian 02-05-2007
Posted by Xiong Changnian on February 5, 2007, 12:15 pm
Please log in for more thread options
I've browsed my fingers off, read all the obvious sources and quite a
few that are off-topic for my needs. I've even been to the local
computer bookstore; there are many books on OO Perl, each with a hefty
price tag. I'm not cheap; I'm broke.

There seems to be little online between perltoot and the like; and
highly specific discussions that assume advanced knowledge and dive into
esoterics. I don't see the bridge -- general intermediate discussion of
OO Perl.

Here are the kinds of questions I've been trying to answer for myself:

* What is all this about makefiles and installation? Why isn't it enough
to download a module and un-tar it to my lib directory? Perhaps I'm
handicapped, running MacPerl under OS 9. I haven't been able to install
anything I've downloaded, not even stuff that shouldn't have anything to
do with the Mac file system.

* All the CPAN modules seem to be just one class per module; every
source I've read says you *can* declare more than one package in a file
but it seems that in practice, it's one class, one package, one module,
one file. Yet I'm contemplating a set of perhaps 20 closely related
classes. I don't know if I'm taking the wrong approach or if there's a
way to bundle them neatly. And yes, I've read a little on CPAN bundles;
I'm still in the dark. I suspect this question ties into the last.

* The *use* pragma makes a class available in a given file but doesn't
seem to propagate; I have to *use* the class everywhere I, well, use it.
Is there no single place I can declare an entire set of classes for use
in any script that *uses* that file? This obviously ties into the last.

* Same question, different angle: If I *use* and inherit among a group
of classes, it seems I run into dependency problems. Is this a lack of
clear thinking on my part and I need to draw up a strict table of
dependencies and work out the order in which the compiler sees
declarations? Or can I just throw everything in if I declare them the
"right" way?

* What's all this about test suites? I can understand writing a script
that stands on its own and exercises a module. I see discussions that
look as though these test scripts are being generated automatically in
some way.

* Should I *always* use strict and use warn? I've been doing just that,
beating the code until it works under these conditions. I see a lot of
code online that shouldn't, though. Right now, I'm using symbolic refs
in one place and I feel I oughtn't.

Nobody has to take the time to answer any of these questions *here* but
I'd love a pointer or five.

Xiong
--
Xiong Changnian
xiong102ATxuefangDOTcom

--
Posted via a free Usenet account from http://www.teranews.com


Posted by Scott Bryce on February 5, 2007, 12:43 pm
Please log in for more thread options
Xiong Changnian wrote:

> I've browsed my fingers off, read all the obvious sources and quite a
> few that are off-topic for my needs. I've even been to the local
> computer bookstore; there are many books on OO Perl, each with a hefty
> price tag. I'm not cheap; I'm broke.

The public library is your friend. My local library has a copy of
Damian Conway's Object Oriented Perl.

Posted by Charlton Wilbur on February 5, 2007, 1:10 pm
Please log in for more thread options

XC> * What is all this about makefiles and installation? Why isn't
XC> it enough to download a module and un-tar it to my lib
XC> directory? Perhaps I'm handicapped, running MacPerl under OS
XC> 9. I haven't been able to install anything I've downloaded,
XC> not even stuff that shouldn't have anything to do with the Mac
XC> file system.

First off, you are indeed handicapped by running MacPerl under OS 9.

It isn't enough to simply download a module and un-tar it because a
number of other files may need to be changed. The module installation
process also includes ensuring the module is as packaged, that all
prerequisites are in place, and that all necessary files (such as
those used to generate perldoc perllocal) are updated. Some modules
also have stubs to link to C libraries, which require a C compiler.
Because Perl was conceived on Unix, the most obvious way to manage all
this was with Makefiles.

On platforms that don't include compilers and Makefiles, alternative
approaches have been developed, from BSD ports and packages to
ActiveState Perl package repositories. Unfortunately for you, OS 9 is
neither Unixlike nor actively supported, which means you're out of luck.

If you insist on not upgrading to OS X, you might consider getting an
external drive and installing one of the PPC Linuxes on it. If you
insist on remaining on OS 9, you need to prepare yourself for a lot of
frustration and annoyance.

XC> * What's all this about test suites? I can understand writing
XC> a script that stands on its own and exercises a module. I see
XC> discussions that look as though these test scripts are being
XC> generated automatically in some way.

They aren't necessarily generated automatically, but if you conform
with the behavior expected by Test::Simple and its relatives, you can
run them automatically during development and run them automatically
at installation time.

XC> * Should I *always* use strict and use warn? I've been doing
XC> just that, beating the code until it works under these
XC> conditions. I see a lot of code online that shouldn't,
XC> though. Right now, I'm using symbolic refs in one place and I
XC> feel I oughtn't.

Yes, you should *always* use strictures and warnings, especially as
they're both scoped, and when you need to do something that violates a
stricture or warning, you can turn that diagnostic off in the smallest
possible scope. Even then, there's almost always a better way.

XC> Nobody has to take the time to answer any of these questions
XC> *here* but I'd love a pointer or five.

As to your questions about OO syntax and inheritance --
_Object-Oriented Perl_, by Damian Conway. Good luck.

Charlton


--
Charlton Wilbur
cwilbur@chromatico.net

Posted by Xiong Changnian on February 5, 2007, 4:04 pm
Please log in for more thread options

> If you insist on not upgrading to OS X, you might consider getting an
> external drive and installing one of the PPC Linuxes on it. If you
> insist on remaining on OS 9, you need to prepare yourself for a lot of
> frustration and annoyance.

It's difficult to explain why I still run OS 9 and I'm not sure this is
the place for it. Assume all the reasons given by bad managers for
legacy systems and stir in a large helping of poverty. Fact is, I've got
my beige G3 hot-rodded, hardware and software, to an impressive extent.
It works -- most of the time -- very well.

I tried, over a period of about six months, to install various flavors
of Linux on a beige Mac. It was a nightmare. I think the way out of my
corner is to wait until I have enough workspace to set up two
workstations, buy a cheap Intel box and put a standard Linux distro on
it -- never touch windoz -- and go back and forth between the two
systems until I make the transition. Even then, I anticipate a PowerBook
for years to come. There is simply no reasonable way, in some cases, to
convert old work files.

> if you conform
> with the behavior expected by Test::Simple...

I have plain Test installed and I looked over the POD before I posted
here. It assumes I already know what the author is driving at. I'll
exercise it a bit and see what happens. I'm afraid I'm not really an
experimentalist at heart; I like to read the manual. I've been looking
at a number of files shipped with MacPerl with the extension .t as well.
I suspect I will learn something.



> The public library is your friend. My local library has a copy of
> Damian Conway's Object Oriented Perl.

I should have thought of that. This *is* San Jose. Even $21.50 for the
PDF is too rich for my blood.



> Just grep for package over all pm
> files and I am sure you will find modules already installed that have more
> then one class per pm file.

I've been looking for such examples; I'll look harder.

> Unless they are very short (linewise) you might be better of to put each
> in a file of their own. Or a combination. 20 classes in one file is IMO a
> pain in the ass to edit, even if you can split your window in 2 or more
> views.

You're right, of course. But 20 files is also a kind of pain. I think a
balanced hierarchy would be something like 5 distinct files, one each
for important, complex classes; plus another 2 or 3 files containing
these itty-bitty classes that have only perhaps 2 methods each.

> Show the code. The nice thing of use warnings is that you can disable
> warnings for a block.

I posted that before. Here again:

sub report_sets {
my @keys = sort keys %{ $ref-> };
foreach (@keys) {
&{"report_" . lc($_)} ($ref->)
or die ("No report subroutine for $_.");
};
};

Many such subs, one for each hash key; some actually do something.
Symbolic ref, so I bracket this with no strict "refs";

It *does* work but I'm pretty sure there *is* a better way; I just have
to make every hash level an object -- which leads to a proliferation of
"internal" classes, most obviously named after the hash keys which
invoke them. Thus my worries about -- "bundle bloat"?


wrote:

> By "the like", do you mean perlobj, perlboot, perltooc, perlmod and
> perlbot?

Yes, Sir, I believe I've read them all three to seven times. They're
pretty basic. There may still be stuff to be gleaned from them but I
look forward to paging through Conway.

> > * All the CPAN modules seem to be just one class per module;
>
> Look at more modules. Tie::File, for example, has two helper classes.
> And that is not unusual.

I don't have Tie::File handy but I'm just now looking over Tie::Array,
which has in the file both package Tie::Array and package Tie::StdArray;
and I will study this until I see how it works. Good tip.

> > * The *use* pragma makes a class available in a given file but doesn't
> > seem to propagate;
>
> Could you give an example?

I'd better put a lengthy code example in another post. First, I want to
strip out all possible dead wood. Thanks for the invitation.

And many thanks to all for the extensive help.

Xiong
--
Xiong Changnian
xiong102ATxuefangDOTcom

--
Posted via a free Usenet account from http://www.teranews.com


Posted by Charlton Wilbur on February 5, 2007, 4:43 pm
Please log in for more thread options


>> If you insist on not upgrading to OS X, you might consider
>> getting an external drive and installing one of the PPC Linuxes
>> on it. If you insist on remaining on OS 9, you need to prepare
>> yourself for a lot of frustration and annoyance.

XC> It's difficult to explain why I still run OS 9 and I'm not
XC> sure this is the place for it.

It doesn't matter, and it isn't. What I said, I stand by; the fact
that you have very good reasons to remain on OS 9 will not alter the
frustration and annoyance.

Charlton



--
Charlton Wilbur
cwilbur@chromatico.net

Similar ThreadsPosted
Webcool24.com : Biggest worldwide Asian free Video multi language web , Travel, Sports, Racing cars , Massages techniques, Games , Fashions, Jokes , Top models , Free online IT learning , 5000 links, 250 free online TV , 50000 music video, nice la August 15, 2007, 8:58 am
The Convenience of Online Learning. The Benefits of a Respected Degree.Try Ellis College for Free. July 21, 2007, 6:04 pm
online perl... March 25, 2005, 3:14 pm
PERL TK Online tutorial May 30, 2006, 12:16 am
Perl and Online Banking November 25, 2006, 1:54 pm
I'm looking for online lecture for perl language? March 25, 2005, 3:12 pm
Good online tutorials on Perl November 1, 2005, 3:31 pm
Online forum source codes in Perl/CGI without SQL? October 23, 2004, 12:00 am
Online Graphing Calculator - Perl Backend June 22, 2006, 11:11 pm
Perl code to fill-in online form March 21, 2008, 7:57 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap