package filtertest; use Filter::Util::Call; use strict; use warnings; use feature "switch"; sub import { my $self = @_; my $ref = []; filter_add( bless $ref ); } sub filter { my $self = @_; my $status; $status = filter_read(); die "some thing messed up" if $status < 0 ; die "EOF reached" if $status == 0; given( $_ ){ when (/^say*/) { print "\n%%reaching here as $_ was matched%%"; s/say/print/; print "\n%%It was changed to $_%%"; } when ( /^use/ ) { print "\n&&reaching here as $_ was matched&&"; } default { print "\n**default condition**" } } $status; } 1;