sub open_directory {
my $directory = shift @_;
my @files = ();
opendir (my $dh, $directory) or die "Couldn't open dir '$directory' : $!";
my @all_files = readdir $dh;
closedir $dh;
foreach my $files(@all_files){
while($files =~ /\.htm/){
push(@files);
}
}
return @files;
}
The error is at the code push(@files);
The error is :
Useless use of push with no values
I want to process the files with the the name ending of .htm or .html in the @files array using the regex /\.htm/ please help me.
whileshould really be anif.push(@files, $files);