in reply to confused (and frustrated) about stdin/out

open2() is from the module IPC::Open2.
From `perldoc IPC::Open2`:
This whole affair is quite dangerous, as you may block forever. It assumes it's going to talk to something like bc, both writing to it and reading from it. This is pre­sumably safe because you "know" that commands like bc will read a line at a time and output a line at a time. Pro­grams like sort that read their entire input stream first, however, are quite apt to cause deadlock.
  • Comment on Re: confused (and frustrated) about stdin/out

Replies are listed 'Best First'.
Re: Re: confused (and frustrated) about stdin/out
by smackdab (Pilgrim) on Dec 03, 2001 at 05:19 UTC
    We'll that's embarassing ;)

    Know of a command or module that would allow me to emulate the way sort works?

    -thanks
      You mean besides sort?
      # With each line in @unsorted @sorted = sort @unsorted; # With all lines in $unsorted, maybe use IO::String my $S = new IO::String \$unsorted; @sorted = sort <$S>; # Or just split on newlines, maybe reversed too: @sorted = reverse sort split $/, $unsorted;
      Consider File::Sort for anything more complex.