in reply to Re: the greedy diamond, or leggo my STDIN
in thread the greedy diamond, or leggo my STDIN

Ah hah! I just did this.

close(STDIN); open(STDIN,"<","/dev/tty") or die "Can't reopen STDIN from /dev/tty: $ +!";

I don't know if it's any better or worse than using a new filehandle, but it keeps me happy.

BTW: What would I do on a non-posix system?

Replies are listed 'Best First'.
Re^3: the greedy diamond, or leggo my STDIN
by blazar (Canon) on Jul 03, 2007 at 20:37 UTC
    I don't know if it's any better or worse than using a new filehandle, but it keeps me happy.

    It's exactly as the same IMHO and in both ways it keeps me unhappy: I find your way to do what you want to do clumsy and error prone, which is probably the reason why I couldn't understand your question at all, first.

    BTW: What would I do on a non-posix system?

    But seriously, why don't you use <>'s magic instead?

    q:~/tmp [22:37:14]$ cat headybrew.pl #!/usr/bin/perl chomp(my @msg =<>); print @msg, "\n"; print "What do you want to do with this message?"; $response = <STDIN>; print $response; q:~/tmp [22:37:17]$ ./headybrew.pl 'ls|' headybrew.plheadybrew.pl~ What do you want to do with this message?foo foo