my $word = 'BLAHBLAH'; print blah(grep{s/BLAH/COW/}$word); sub blah { my $stuff = shift; return "$stuff\n"; }