in reply to Remote interpreter (redefining print())

Check out this for info about why you can't override print.

As for redirecting STDOUT to your socket, you'd probably want to use the dup form of open:

open STDOUT, ">& $fh" or die;.

Not totally sure if that will work for socket handles or not, and you most likely want to save a copy of the old STDOUT as well.

HTH.

Update: Oh, and for info on why your typeglob assignment might not be working, check out this node.

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.

Replies are listed 'Best First'.
Re: (bbfu) Re: Remote interpreter (redefining print())
by no_slogan (Deacon) on May 08, 2001 at 01:49 UTC
    You need to use the file descriptor, not the file itself:
    $fd = fileno($fh); open STDOUT, ">&$fd"
    Yes, this works for sockets. The typeglob assign just needs another star:
    local *STDOUT = *$fh;

      You need to use the file descriptor, not the file itself:

      Right, that's it. :-) I'm used to duping regular typeglob-style filehandles, in which case you can just use the name. But you're right that you need the fd for anonymous symbol-table entries (a la FileHandle).

      The typeglob assign just needs another star:

      Cool. I knew there was a way to do that but couldn't think what it needed. Good catch.

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.