#!/usr/bin/perl use warnings; use strict; sub doit { print "How are you?\n"; } seek DATA, 0, 0; while () { print if /^sub doit {/ .. /^}/ } __DATA__