Add the name of the input file to a string as the name of the output file
14:32 25 Jan 2018

I have loaded my input file using open. I want to concatenate the name of the input file with the string 'matched_results', and use that as a name for my output file.

Here is the code I have:

use File::Basename;
open(text, ") {
    push @matches, $1 while $line
        =~ m{
          (###some regex here)
        }xgi;
}    

$base = basename $text;
my $filename = "matched_results${base}.txt";
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh "$_\n" for @matches;
close $fh;

I get the following message:

Use of uninitialized value $_[0] in substitution (s///) at /usr/share/perl/5.18/File/Basename.pm line 341,  line 1.
perl