Segfault has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a Perl script that will open a FIFO that a web browser reads from and writes to (specifically, a FIFO in place of the bookmarks file). I want to be able to supply information from the script through the FIFO whenever the browser tries to read the file, but I also want to be able to catch any data the browser writes back to it (i.e. a new bookmark has been added).

How would I go about doing this?

Replies are listed 'Best First'.
Re: Bidirectional FIFO
by toiletmonster (Novice) on Oct 30, 2002 at 21:04 UTC
    interesting. what does your script do exactly. just curious.

    i don't think using a FIFO to do this is a good idea. think about what a FIFO is: first in first out. try stepping through the reading and writing between the two processes on paper and be sure to draw your FIFO for each step. there is going to be some horrible unavoidable deadlock here. its just not possible with a fifo, unless you are also the author of the browser.

    i'd try something else. do a diff on the bookmarks file. i don't know... there's gotta be a better way than that though.

    if you give more context to what you are trying to do, maybe i could give a better suggestion.
Re: Bidirectional FIFO
by fglock (Vicar) on Oct 30, 2002 at 21:00 UTC

    I'd start by trying out the examples at perlipc.

Re: Bidirectional FIFO
by Segfault (Scribe) on Oct 31, 2002 at 03:08 UTC
    Basically what I'm trying to do is assemble a program that will serve a common set of bookmarks to browsers from a centralized location. i.e. There'd be a server that would have the actual bookmarks stored, and clients would reference it when the FIFO was read from by the browser, tell the server about new bookmarks that have been added or changed on their end, etc.

    I suppose I could just have the clients keep an eye on the bookmarks file for changes, and diff it, but I was hoping for something a little more transparent and a FIFO seemed like a good idea, until I actually started trying to code it anyway. :)