use strict; use warnings; my @strings = ( 'string that I need to gather the common base from: number 1 and some other junk in it', 'string that I need to gather the common base from: number 2 and some other junk in it', 'string that I need to gather the common base from: number 3 and some other junk in it', 'string that doesnt meet the proper specifications: number 4 and some other junk in it', 'another string that will fail to match: because it doesnt match DUH!', 'this string will fail as well' ); for(@strings){ print $1 . $2 . "\n" if (/^(string that I need to gather the common base from:\s)(.*)/); }