I have created a Perl program that iterates the lines in a log file and passes each line to a processor. I plan on implementing many processors. I have implemented each processor as a module. Each module has a common set of subroutines: init, process, and finish. I declare each processor with a seperate package name and include something similar to the following:
package coloTotals; require Exporter; use strict; our @ISA = qw(Exporter); our @EXPORT = qw(init process finish); our $VERSION = 1.00; sub init { ... } sub process { ... } sub finish { ... }
When i run the program with more than one processor defined, I get:
Subroutine init redefined at lib/perl5/5.6.1/Exporter.pm line 57. Exporter::import('init', 'process', 'finish') called at load.p +l line 10 main::BEGIN() called at ModView.pm line 10 eval {...} called at ModView.pm line 10 Subroutine process redefined at lib/perl5/5.6.1/Exporter.pm line 57. Exporter::import('init', 'process', 'finish') called at load.p +l line 10 main::BEGIN() called at ModView.pm line 10 eval {...} called at SbModView.pm line 10 Subroutine finish redefined at lib/perl5/5.6.1/Exporter.pm line 57. Exporter::import('init', 'process', 'finish') called at load.p +l line 10 main::BEGIN() called at ModView.pm line 10 eval {...} called at ModView.pm line 10
Does anyone know how to resolve this issue. The program still functions properly, but I want to learn the appropriate way to implement a program like this and also to remove these warnings. Does anyone have some sample code for implementing an OO program similar to this?

In reply to Encapsulation and Subroutine redefined warnings by jspeaks

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.