Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:13:22+00:00 2026-05-23T16:13:22+00:00

I’m still new to moose, but it has me drooling! Below is a simplified

  • 0

I’m still new to moose, but it has me drooling! Below is a simplified version of what I would like to do: generate object dependent input files that may be used to run an external program. These external programs can be intensive computationally, and I will process the output back into the objects many times each for many objects (as a function of some external parameter tweaking). The module below works (I think), but there may be better/cleaner ways to do this. What is the proper way to do this? Since all these objects live in their own little world, it seems as though I should be able to run batches of these in parallel to efficiently chomp through the collection of objects. Any tips for this!??

{
package input_genrun;                                              
use Moose;                                                         
use IO::Pipe;                                                      
use FileHandle;                                                    

has 'name', is => 'ro', isa =>'Str';
has 'exe'      => (                 
                    is  => 'ro',    
                    isa => 'Str',   
                    default => '/usr/local/bin/bar',
                  );
has 'inp_fh'   => (
                    is => 'rw',
                    isa=> 'FileHandle',
                    default => sub {
                      my $handle = FileHandle->new;
                      return $handle;
                    }
                  );
has 'out_fh'   => (
                    is => 'rw',
                    isa=> 'IO::Pipe',
                    default => sub {
                      my $handle = IO::Pipe->new;
                      return $handle;
                    }
                  );

sub inp_wrt
{
  my ($self,$object) = @_;
  my $filename = $object->name() . ".inp";
  my $fh = FileHandle->new;
  $fh->open(">" . $filename);
  print $fh "foo \n";
  print $fh "bar \n";
  $fh->close;
}

sub run
{
  my ($self, $object) = @_;
  my $name = $object->name() . ".inp";
  my $exe = $self->exe;
  my $command = $self->exe . " $name";
  $self->out_fh()->reader($command);
  return($self->out_fh());
}

} 

my $l = input_genrun->new(name=> 'foo_l',exe=> 'wc');
my $m = input_genrun->new(name=> 'foo_m',exe=> 'cat');
my $n = input_genrun->new(name=> 'foo_n',exe=> 'tac');

$l->inp_wrt($l);
$m->inp_wrt($m);
$n->inp_wrt($n);

my $pipe_l = $l->run($l);
my $pipe_m = $m->run($m);
my $pipe_n = $n->run($n);

while (<$pipe_l>){
  print "from_l: $_";
}
while (<$pipe_m>){
  print "from_m: $_";
}
while (<$pipe_n>){
  print "from_n: $_";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:13:22+00:00Added an answer on May 23, 2026 at 4:13 pm

    I’d start by taking a look at MooseX::Workers which abstracts around POE::Wheel::Run to solve this same problem. Failing that I’d look at a number of the other asynchronous job handlers out there (Parallel::Fork, Proc::Simple::Async, Gearman, etc.) before really going to tackle implementing the wheel again.

    If nothing else they’ll give you a good idea of what has been done before in this space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.