Class::DBI and CGI::Application make heavy use of inheritance, as does Exporter, though I wouldn't really call that OO--it's more like using Perl's OO-ish features in a non-OO way.

Right now, I'm in the middle of a project that needs to generate reports based on certain data. The reports could come out in HTML, PDF, Excel, or even a CSV for exporting to another system. I've worked this by having an ExportFormat class which specific report formats inheirt from. After the constructor is called, a record() method is called many times with the argument as a single row from the database (actually, a Class::DBI subclass containing a single row). When the application is done filling the data, it calls a done() method, which returns a filehandle that contains the completed report. Since this is a web application, each report also has a mime_type() method that gives the MIME type that should be sent back to the client for this report.

I find this solution to be quite elegant.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated


In reply to Re: Real live usage of inheritance? by hardburn
in thread Real live usage of inheritance? by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.