Perl "pipe" command, cant print binary to handle

Discussion in 'Perl Misc' started by David, Jan 31, 2005.

  1. David

    David Guest

    Hey all, I'm working on a script that reads from STDIN. This will
    be "use"ed by other scripts. These other scripts may be useing other
    lib's which want to read from STDIN as well.
    So I've written this code which works great for re-populating STDIN
    except for when I try to print binary to the handle.

    my $input = join('', <STDIN>);
    close(STDIN);
    pipe(STDIN, TOSTDIN);
    print TOSTDIN $input;
    close(TOSTDIN);

    in the senario where I get an image file submited via the web, it hangs
    when tring to "print TOSTDIN $input;".

    Any ideas?

    Thanks,
    David
    David, Jan 31, 2005
    #1
    1. Advertising

  2. David

    Guest

    David wrote:

    > pipe(STDIN, TOSTDIN);
    > print TOSTDIN $input;


    > it hangs when tring to "print TOSTDIN $input;".


    A pipe is a pipe not a storage medium. You can only put so much in
    before you have to wait for somthing to start taking stuff out the
    other end.

    You probably wanted:

    open STDIN, '<', \$input;
    , Feb 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lee, wonsun
    Replies:
    1
    Views:
    478
    Jack Klein
    Nov 2, 2004
  2. Leon
    Replies:
    2
    Views:
    508
  3. Nagaraj
    Replies:
    1
    Views:
    837
    Lionel B
    Mar 1, 2007
  4. Replies:
    10
    Views:
    253
  5. Replies:
    1
    Views:
    215
    Ben Morrow
    Jun 2, 2004
Loading...

Share This Page