Well, you separate out:
my @contractors = split(m#\s+#, $1);
where
$1 is actually everything after
$string. But then you try in your
while( <$contin> ) { loop
if ( $contractors =~ m/^$string(.*)/ ) Depsite the fact that
@contractors has already been regexed away from
$string. Its hard to visualize without seeing some example input and output you are after, but you might not want to be matching
$string multiple times like that, especially if
$contractors is just an element of the array of stuff *after*
$string.