Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I like the "more ideal" solution of having separate text filters. Since Text::Filter is taken, how about Text::Pipe? After all, the factory method shouldn't be able to just give you one filter, but several filters, piped together.

    And I wouldn't put the factory in a ::Common module; just call it Text::Pipe::Factory. It generates "pipe segments" that are Text::Pipe::* objects, all of which are derived from Text::Pipe::Base.

    Several pipe segments, piped together, could themselves be pipe segments.

    Text::Pipe::*
    • I don't care much about names, but I disagree letting Text::Pipe itself have the stackable several filters becasue all filters have the same single filter interface, you don't need to.

      Creating a stacked pipe is easy by creating a new Pipe stacker object, like:

      use Text::Pipe::Stackable;
      use Text::Pipe;
       
      my $pipe1 = Text::Pipe->new('foo');
      my $pipe2 = Text::Pipe->new('bar');
      my $pipe3 = Text::Pipe->new('baz');
       
      my $stacked_pipe = Text::Pipe::Stackable->new($pipe1, $pipe2, $pipe3);
       
      my $output = $stacked_pipe->filter($input);
      And I also don't care much about the class structure as well, but it needs to be easy and less code enough for more developers to be able to write a new adapter for a new text filtering engine.

      But well, it seems like a bike-shed discussion to me. The detailed API could be improved anytime once the development starts. The important thing is to know if it's a good thing or completely useless.

      I'm also interested in writing a pipe for arbitrary data structure like reduce() or trim() that works on array ref. Go look at Test::Base::Filter module that INGY created a while ago. It has several filter function that operates both on string and array.
      • Agreed re bike-shed discussion; one more point though:

                my $stacked_pipe = Text::Pipe::Stackable->new($pipe1, $pipe2, $pipe3);

        Yes, that's a better design pattern. In that case, Text::Pipe::Stackable->new() should be able to take both individual segments as well as Text::Pipe::Stackable objects as well (for a kind of recursive construction).

        That is, stacked pipes should - to the user - be indistinguishable from individual pipe segments. It's just some black hole that has an i