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

Greetings all, I've had a module that I wrote to do some writing of a custom file format here at work. For a while, I've been thinking of writing a tied interface to it to make the magic happen behind the scenes. However, I've been reading a bit about PerlIO layers and thought that that might be the way to go.

First things first: is one preferable over the other? I'm at the point where I don't know what I don't know...entirely clueless about the whole situation. I'm happy to do the reading, but don't know where to start.

Secondly, even if tying is the way to go, I would still like to do the PerlIO layer as an academic exercise. I tried following PerlIO::via::QuotedPrint, but I keep getting "Function not implemented", which at my level of education on the subject isn't terribly helpful. I tried to read perliol, but I'm not enough of a C-head to fully grasp it. If someone has a pointer to some higher level docs, I'd sure appreciate it.

thor

Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come

Replies are listed 'Best First'.
Re: Making my own PerlIO layer
by Zaxo (Archbishop) on Sep 08, 2004 at 17:05 UTC

    Have you seen the pod for PerlIO::via? That gives you the interface specs you need. It's very similar to a tied class in spirit.

    You've probably seen that, since you mention the QuotedPrint example. What function is not implemented? What does your attempt look like?

    I've used liz's PerlIO::via::MD5 in practical applications. You may get some help by examining that module, too.

    After Compline,
    Zaxo

      So far, I've only implemented the PUSHED routine, as the docs seem to indicate that that's all that's required. I would have thought that OPEN would have been required, but I gather that if it's not implemented, it will defer to the next lowest layer.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come

Re: Making my own PerlIO layer
by Steve_p (Priest) on Sep 08, 2004 at 17:14 UTC

    I'm not sure on any additional documentation, but Chia-liang Kao has been working on a few additional PerlIO::via classes as well, so you might get some additional ideas there as well.

Re: Making my own PerlIO layer
by thor (Priest) on Sep 10, 2004 at 12:16 UTC
    Update:Sorry I haven't been more forthcoming on this. I rna into a project that's consumed a lot of my time. My original module looks like this: My attempts at the PerlIO layer thus far are pretty pitiful. I guess I'm not understanding what the purpose of the PUSHED function is vs the OPEN function. From what I can tell, my OPEN will just be a call to my rdw_open. Similarly, FILL is just a wrapper around read_rdw and WRITE around write_rdw. I can't for the life of me figure out what PUSHED is supposed to do, however.

    Also, feel free to comment on the original module. Perhaps there's some modifications that could be made there that would make the work here easier.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come