Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Wednesday June 05, 2002
08:34 AM

No action required

[ #5432 ]
IOLayer::StripHTML has been uploaded to CPAN. That's a small input-only perlio layer, written in perl, whose idea was suggested at the latest meeting. Next step is to write the output-only counterpart. Further step may be to write a small article about it, first in a hypothetical series what's new in the shiny world of Perl 5.8.

P.S. If you like closures, this module (although very short) uses some of them in an interesting way. There's even an lvalue closure. Cool.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm definatly looking forward to some of the interesting things in 5.8.

    One small point, don't you seem to call $p->eof. I've had odd things happen sometimes without it.

  • This is of course incredibly cool. I've been toying with the idea of making one myself, but I can't seem to find docs on how one passes arguments to a layer (say open $fh,"<:Via(Foo::Bar=arg1,arg2)"; ?). The docs for PerlIO::Via haven't been very helpful there (or I've been very dumb).


    -- Robin Berjon []

    • In fact, in your example, Foo::Bar=arg1,arg2 is an argument passed to the "true" layer PerlIO::Via via its Getarg function (the proper documentation about this is in the perliol man page.) PerlIO::Via interprets it as a class name, on which the tie-like functions should be called. To do anything more complicated, you should write your layer in C.
      • Hmm, that's a pity. I was hoping that PerlIO::Via would have argument passing semantics (as the above would be an illegal class name) so that arguments could be passed to the layer.

        The reason I came up with this was while thinking about IOLayer::XSLT. One would need to provide the path to the stylesheet as an argument, and if one can't then there's no way of implementing that module.

        I'll look into subclassing PerlIO::Via to see if that could work, as I would very much like to avoid having to


        -- Robin Berjon []

        • I don't think that subclassing PerlIO::Via is going
          to work. In fact the internals of this thing are not very clearly documented and I'm just beginning to get how it works.

          To keep it simple, I suggest action-at-distance :

          my $fh = do {
              # this global variable is read at push-time
              local $IOLayer::XSLT::path = "....";
              open my $fh, ">:Via(IOLayer::XSLT)", "..."
                  or die $!;
          • I very much doubt subclassing will work either, in fact I tried and it didn't appear to do anything, though I might have done it wrong.

            Action-at-a-distance is out of the picture, either it can be done cleanly or I won't bother. One thing I thought about was $fh->setPath('/path/to/file.xsl') but that's not really satisfying, if indeed it does work (I'm pretty much sure it won't if IOLayer::XSLT isn't the last one in the stack).

            I don't have much time to consecrate to this, but my current pla


            -- Robin Berjon []

            • Hey, that's not a perl limit, that's a limit in the particular PerlIO::Via module. You can do it very differently if you wish. You can implement PerlIO::ViaWithArgs that will do what you want. (It's a bit late to submit a code patch for 5.8.0.) Note that the whole perlio functionality is new and needs to be proof-tested with production code. Nick Ing-Simmons' amount of work to get this done was unbelievable.
              • Sorry, I didn't mean to imply that this was a Perl limit, just a limit in an implementation of something that ships with Perl.

                I very much know that I can go ahead and implement a different Via module, I just wish that it were in this module (note: I'm not complaining, otherwise I'd be working on that right now and sending stuff to p5p). Part of this idea was precisely to implement something that would help test perlio, it's in fact the main reason why I grabbed RC1 (apart from checking that my stuf


                -- Robin Berjon []