Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all

I am able to execute the below program in perl but NOT in mod_perl

$pid = open2(*Reader,*Writer,$test_cmd);
Writer->autoflush();
Reader->autoflush();

print Writer "mypwd\n";
while (<Reader>) {
$output .= $_;
}

In mod perl , whatever I write to Writer using "print Writer " does not get reached to my program defined in $test_cmd. This works perfectly fine with only perl but not with mod perl,what might be the reason and any workaround

Any help would be greatly appreciated

Thanks
Sajid

Replies are listed 'Best First'.
Re: open2 does not work in mod perl
by agianni (Hermit) on Jun 12, 2007 at 20:15 UTC
    A Google search on mod_perl open2 provides some insight. Seems that open2 doesn't play nice with mod_perl, but there are some workarounds
    perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'
Re: open2 does not work in mod perl
by ides (Deacon) on Jun 12, 2007 at 18:32 UTC

    It *might* be because of the globs. Try this:

    my($reader, $writer); $pid = open2($reader, $writer, $test_cmd);

    Not sure it will make a difference, but worth a try.

    Frank Wiles <frank@revsys.com>
    www.revsys.com

      No, it is not due to globs, I tried with locals, yet it fails