This has got to be obvious but I\'m just not seeing it.
I have a documents containing thousands of records just like below:
Row:1 DATA:
[0]37755442
[
my($foo) = $record=~ /Defect/;
print STDOUT $foo;
Rather than this you should do
$record =~ /Defect/;
my $foo = $&; # Matched portion of the $record.
As your goal seems to be to get the matched portion. The return value is true/false indicating if match was successful or not.
You may find http://perldoc.perl.org/perlreref.html handy.