I have a simple perl code that displays the names of the files in a given directory
opendir my $dir, "./images/sampleImages" or die "Cannot open directory: $!";
my @Images = grep {!/^\./} readdir $dir;
closedir $dir;
Run Code Online (Sandbox Code Playgroud)
I have added a regex statement to remove all single and double dots, since readdir adds them as special characters and this is working perfectly fine. However I want only the files with the extensions of .jpg/.jpeg/.png/.gif to be read. I have found a …