Warning!! What follows is just my curiosity in trying to solve the problem. It works as far as I have tested it, and that is exactly as far as you can see from the simple code that follows. Critisisms invited.

Using this main program

#! perl -sw use vars qw/@scanners/; use strict; use constant PLUGINS => 'c:/test/plugins/*'; BEGIN { @scanners = glob PLUGINS; for(@scanners) { require $_; warn $@ if $@; my ($module) = m!.*/([^\.]+)\Q.pm\E$!; $_ = eval{ "$module"->new() }; warn "Attempt to load: $module failed\n" if ( !$_ or $@ ); } @scanners = grep{ $_ } @scanners; } # call the 'scan' routine in each module, and # print out the results from the array reference returned. print @{&{$_}}, $/ for @scanners;

And these two modules

package method1; sub new{ my $class = shift; return bless \&scan, $class; } sub scan{ my @results = qw/foo bar baz/; #!do scan; return \@results; } 1;

method2.pm

package method2; sub new{ my $class = shift; return bless \&scan, $class; } sub scan{ my @results = qw/the quick brown fox/; #!do scan; return \@results; } 1;

I get these results.

C:\test>209857 foobarbaz thequickbrownfox C:\test>

which seems to indicate that the method works. However, whilst I cannot see anything wrong with the mechanism, it's the first time I tried anything like this so I am fully expecting to be told either that there is a much simpler way of doing this, or that there is something fundementally unsound in what I have done.


Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy

In reply to Re: Similar plugins run serially by BrowserUk
in thread Similar plugins run serially by gomez18

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.