[ic] IPC::Open2 inside GlobalSub

Sam Hui shui@lunamedium.com
Wed, 7 Mar 2001 15:41:28 -0800


I'm trying to encrypt some data using a globalsub and an external binary,
but somehow the $data isn't getting out to the $encrypt_cmd via "Writer"
handle.  This code runs perfectly fine on a perl script by itself...  I'm
not getting any errors and using the ::logDebug statements, the code is
being excuted and the $encrypt_cmd is being called.  I know this because
open2 returns a different process id everytime the code runs.  Could someone
shine some light on this?  Much appreciated.

GlobalSub <<EOS
sub encrypt_some_data {

    use FileHandle;
    use IPC::Open2;

    my $rec_data;
    my $pid = eval{
        open2(\*Reader, \*Writer, "$encrypt_cmd");
        print Writer "$data";

        local($/) = undef;
        $rec_data = <Reader>;