That does make sense. However, I think your problem is in this loop:
while ( <$contin> )
{
if ( $contractors =~ m/^$string(.*)/ )
{
my @results = split(m#\s+#, $1);
print br;
print @results;
}
}
close( $contin );
}
Specifically I think you're running into a problem at
if ( $contractors =~ m/^$string(.*)/ )
It looks like what you want to be doing is matching every line in
$contin against your current
$contractor where what you're actually doing is matching
$contractor against your regex
^$string(.*) Try changing the above regex in the while loop to have something like
while ( <$contin> )
{
if ($_ =~ m/^$contractor(.*)/)
{
my @results = split(m#\s+#, $1);
print br;
print @results;
}
}
close( $contin );
}