# following line stolen shamelessly from belg4mit's post while( /(?<=H)5+(?=H)/g ){ print $-[0]; }