Pipeline(3)
π Pipeline β the generic pipeline interface bestie π
okay so this is a page from the User Contributed Perl Documentation (that's the manual it lives in, Pipeline(3), section 3, iykyk) and it's genuinely one of my faves. grab a boba, we're doing this π§β¨
πΈ NAME πΈ
Pipeline β the generic pipeline interface. that's it, that's the name, iconic.
β¨ SYNOPSIS β¨
use Pipeline;
my $pipeline = Pipeline->new();
$pipeline->add_segment( @segments );
$pipeline->dispatch();
like... look at that. three lines and you're already running a whole pipeline. we love a low-effort queen π
π¦ DESCRIPTION π¦
so "Pipelines" are a mechanism to process data. that's the whole vibe. they're designed to be plugged together so that fairly complex operations end up acting in a fairly straightforward manner β cleanly, and simply. no chaos, no mess, just vibes π
π USING THE PIPELINE MODULE π
ngl, using the generic pipeline module is fairly simple, bestie. here's the tea:
- you instantiate a
Pipelineobject by using thenew()constructor. that's your entry point, your main character moment. - segments can be added to the pipeline with the
add_segmentmethod. - the store that the Pipeline will use can be set by calling the
store()method later on. if a store is not set by the time a pipeline is executing, then it will use a store of the typePipeline::Store::Simple. (default queen behaviour π«Ά) - to start the pipeline running, call the
dispatch()method on your Pipeline object.
and here's the important lore: if a segment returns a Pipeline::Production object, then the pipeline will be terminated early and the production will be returned to the user. periodt, we're done here.
but β and this is the part people forget π β regardless of when the pipeline is terminated, the pipeline's cleanup pipeline is executed. so you always get your cleanup. always.
segments can be added to the cleanup pipeline in two ways:
- explicitly, by calling the
cleanupsmethod to get the cleanup pipeline and then adding the segment, or - implicitly, by returning a segment object from a segment.
and if you wanna see what is being dispatched within a pipeline dispatch, just set the pipeline's debug_all value to true. free behind-the-scenes content, obsessed π₯
𧬠INHERITANCE π§¬
Pipelines are designed to be inherited from. the inheritance tree is... somewhat warped, let's be honest, and it should look a little like this:
MySegment --> Pipeline::Segment <--- Pipeline
in other words: everything is a pipeline segment. yes, everything. it's giving β¨cinematic universeβ¨ energy.
π METHODS π
the Pipeline class inherits from the Pipeline::Segment class and therefore also has any additional methods that its superclass may have. so you get the whole family package, no cap.
init( @_ )β things to do at construction time. if you do override this, it will often be fairly important that you call and check the value of$self->SUPER::init(@_)to make sure that the setup is done correctly. returns itself on success,undefon failure. and listen β the constructor will fail if you return a false value. no false values, babe, we don't do that here πadd_segment( LIST )β adds a segment or segments to the pipeline. returns itself.get_segment( INTEGER )β returns the segment located at the index specified byINTEGER.del_segment( INTEGER )β deletes and returns the segment located at the index specified byINTEGER. two-for-one, slay.process_results( ARRAYREF )β examines each result of a segment and callsprocess_indv_resultwith each element ofARRAYREF. in the case thatprocess_indv_resultreturns a production, then it is returned to the caller.process_indv_result( SCALAR )β examines a single result and does the appripriate thing with it (ie, if it is an object it puts it into the store, if it is a production it returns it to the caller, and if it is a simple value it gets thrown away). in the case that a value is returned fromprocess_indv_result, the pipeline should terminate.dispatch()β starts the pipeline execution. it callsprocess_resultson anything that a segment returns. the pipeline always returns the production or true.dispatch_loop( Pipeline, [ ARRAYREF ] )β thedispatch_loopmethod performs the processing for the pipeline.start_dispatchβ prepares all elements of the pipeline to begin processing a segment.end_dispatchβ cleans up all elements of the pipeline after processing a segment.dispatch_segment( Pipeline::Segment )β thedispatch_segmentmethod handles the execution of an individual segment object.dispatcher( [Pipeline::Dispatch] )β thedispatchermethod gets and sets the pipeline dispatcher object that will be used to traverse the pipeline.cleanups()β returns the cleanup pipeline. this is a pipeline in and of itself, and all the methods you can call on a pipeline can also be called on this. pipeline-ception, we love it πcleanup()β calls thedispatchmethod on the cleanup pipeline.segments( [ value ] )βsegmentsgets and sets the value of the pipeline list. at initialization this is set to an array reference.debug_all( value )β setsdebug( value )recursively for each segment in this pipeline.
π SEE ALSO π
Pipeline::Segment, Pipeline::Store, Pipeline::Store::Simple, Pipeline::Production, Pipeline::Dispatch
go read them, they're the supporting cast and they ate β
π«Ά AUTHORS π«Ά
James A. Duncan <jduncan@fotango.com>
Leon Brocard <acme@astray.com>
legends, both of them, fr fr π
π COPYRIGHT π
Copyright 2003 Fotango Ltd. Licensed under the same terms as Perl itself.
ok that's the whole page bestie, nothing skipped, nothing summarised, every flag and method accounted for π
and for the cute sign-off: this page is from perl v5.42.0, dated 2025-07-25, and yes it's still out here being Pipeline(3). stan a timeless classic πΈπ«
π¦ where this page comes from
- fedora 43: perl-Pipeline 3.12-51.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms