#!/usr/bin/perl sub fillTemplate { my $funcName = shift; my $index = shift; sub { my $self = shift; sanityCheck($self); ($self->{inTheComment} == 1) ? push @{$self->{killBuffer}}, $_[$index] : $self->SUPER::$funcName(@_); } } for $function ( [ 'declaration', 0 ], [ 'start', 3 ], [ 'text', 0 ], [ 'end', 1 ] ) { *($function->[0]) = fillTemplate($function->[0],$function->[1]); }