Is eval to evil for this? ;)
use strict; use warnings; my $chain1 = chain(qw( rev Foo::uc b2_ )); my $chain2 = chain(qw( Foo::uc b2_ rev )); print for $chain1->(qw( foo bar baz )); print for $chain2->(qw( foo bar baz )); sub chain { my $str = '@_'; $str = '&' . "$_($str)" for @_; return sub { eval $str }; } sub rev { map scalar reverse, @_ } sub b2_ { my @a=@_;map {s/b/_/g;$_} @a } package Foo; sub uc { map ucfirst, @_ }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Composing or chaining subroutines
by jeffa
in thread Composing or chaining subroutines
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |