in reply to Re: Multiple files opened
in thread Multiple files opened

To expand on this:

my $data_file = m/(\w+)/; assigns a true or false value to the variable indicating whether the regular expression matched. To save the captured value, assign the return value of m// from list context, not scalar context.

But if the desired result is to remove the newline, use chomp.