Perl - How to use a process Handle created in a Module in another Perl Script

Posted by Zwik on Stack Overflow See other posts from Stack Overflow or by Zwik
Published on 2010-06-10T14:56:58Z Indexed on 2010/06/10 15:12 UTC
Read the original article Hit count: 468

Filed under:
|
|

Ultimately, what I want to do is to start a process in a module and parse the output in real time in another script.

What I want to do :

  • Open a process Handler (IPC)
  • Use this attribute outside of the Module

How I'm trying to do it and fail :

  • Open the process handler
  • Save the handler in a module's attribute
  • Use the attribute outside the module.

Code example :

#module.pm

self->{PROCESS_HANDLER};

sub doSomething{
  ...
  open( self->{PROCESS_HANDLER}, "run a .jar 2>&1 |" );
  ...
}


#perlScript.pl

my $module = new module(...);
...
$module->doSomething();
...
while( $module->{PROCESS_HANDLER} ){
  ...
}

© Stack Overflow or respective owner

Related posts about perl

Related posts about ipc