package Pipes; use strict; use warnings; use overload '|' => 'pipe'; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(fn); sub new { my ($class, $sub) = @_; bless { sub => $sub }, $class; } sub fn (&) { my ($sub) = @_; new Pipes($sub); } sub pipe { my ($self, $val) = @_; $self->{sub}->($val); } 1;