[clue-tech] text processing howto
David L. Anselmi
anselmi at anselmi.us
Wed Oct 6 22:20:37 MDT 2010
Collins Richey wrote:
> Perhaps some of us should get together and work out an evening of
> little scripting gems from David's list. I've done lots of perl over
> the years, but I refuse to do perl oo code. I can actually understand
> php or ruby oo code, but not perl.
OO Perl is great! It is harder to read/write objects than OO languages, but not any harder to use them:
$dbh = DBI->connect(@args); # this is a class method (a static in Java)
...
$series_id = $dbh->prepare("SELECT nextval('series_id_seq')");
$series_id->execute();
($id, $junk) = $series_id->fetchrow_array();
All the things before -> are objects. No real difference between Perl and Java (Perl's object
references aren't typed of course).
The reason objects are harder to write is that Perl doesn't have special syntax for them (except
perhaps bless()). You make a package, stick in your methods, bless a data structure, and voila.
I get the impression that when the Perl monks heard about objects they looked at what was going on
under the covers and said, "huh, Perl already does that". But it means that it looks very different
than other OO languages.
Dave
More information about the clue-tech
mailing list