I want to fill the folder with copies of the same file that would be called differently. I created a filelist.txt to get filenames using Windows cmd and then the following code:
use strict; # safety net
use warnings; # safety net
use File::NCopy qw(copy);

open FILE, 'C:\blabla\filelist.txt';
my @filelist = ;
my $filelistnumber = @filelist + 1;
my $file = 0;
## my $filename = 'null.txt';
my $filename = $filelist[$file];

while( $file < $filelistnumber ){

rename 'temp.smp', $filename;

$file = $file + 1;

If I try renaming it into 'test.smp' or whatever, it works. If I try the code above, I get this:
Use of uninitialized value $filename in print at blablabla/bla/bla.pl line 25, line 90.
What am I doing wrong? I feel there's some kind of little mistake, a syntax mistake probably, that keeps evading me.

Check Solution