in reply to multiple consumer of an array

Of course that is possible. Perl offers all that is needed; but what is your desired output? Im guessing. You want a pipeline, a.k.a. garbage in- garbage out, so you basically want to return the (possibly modified) input as output, used as input for the next pipeline subroutine.

If you make your stream into an object which is returned by each processor, you can chain your processors like methods:

my $result = $obj->processor_1->processor_2($argument)->processor_3;

If you want to accumulate results for each pass, you could include a result container in the object itself. This is one way to do it, TIMTOWTDI of course:

#!/usr/bin/perl use List::Util qw(min max); use Data::Dumper; my $ary = [12,3,4,5,7,15,8]; my $obj = bless [ $ary, {} ], __PACKAGE__; sub count { $_[0]->[1]->{count} = @{$_[0]->[0]}; $_[0]; } sub min_max { $_[0]->[1]->{min} = min @{$_[0]->[0]}; $_[0]->[1]->{max} = max @{$_[0]->[0]}; $_[0]; } sub esrever { $_[0]->[1]->{esrever} = [ reverse @{$_[0]->[0]} ]; $_[0]; } sub sort_inline { @{$_[0]->[0]} = sort {$a<=>$b} @{$_[0]->[0]}; $_[0]; } sub append_stuff_inline { $_ .= $_[1] for @{$_[0]->[0]}; $_[0]; } my $result = $obj->min_max->append_stuff_inline(".foo")->count->esreve +r->sort_inline; print Dumper($result); __END__ $VAR1 = bless( [ [ '3.foo', '4.foo', '5.foo', '7.foo', '8.foo', '12.foo', '15.foo' ], { 'min' => 3, 'max' => 15, 'esrever' => [ '8.foo', '15.foo', '7.foo', '5.foo', '4.foo', '3.foo', '12.foo' ], 'count' => 7 } ], 'main' );

The first element of the anonymous array $result is the modified array, the second is an anonymous hash containing the output of each pipeline subroutine.

Of course, you could name the first argument to each method (i.e. $_[0]) adequately as $self, that makes no difference, but it might be easier to tell what is going on.

With the above subs, you could also say

my @chain = qw(min_max count sort_inline esrever); my ($result) = map { $obj->$_ } @chain;

which of course doesn't let you pass in additional arguments to the methods called, which is why I didn't include append_stuff_inline() since that would be a no-op..

Perl allows you to

It is up to you how you organize your data, what you pass into your subs, what you modify and what you return.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'