Following up from here: Perl Imgsize not working in loop? I have another question - how do I not let perl list the single and double dot entries when it reads the files in a dir
I have come to another solution, which works for me to delete all files in a subfolder temp - not starting with first file (0) but only with third file (2):
#!/bin/perl
@AllFiles = ();
opendir(DIRECTORY, "temp");
@AllFiles = readdir(DIRECTORY);
closedir DIRECTORY;
print $#AllFiles-1 ."\n"; #Show 3 for three files, as it shows number of last file: 0=. 1=.. 2=aaa.txt 3=bbb.xml 4=ccc.pdf
$FileNumber = 2; #Starting with file 2, don't need to try deleting current and parent folders
until($FileNumber > $#AllFiles ) {
unlink ("temp/" . $AllFiles[$FileNumber]);
print $FileNumber-1 . ": temp/" . $AllFiles[$FileNumber] . "\n"; #show file numbers as 1=aaa.txt 2=bbb.xml 3=ccc.pdf
$FileNumber += 1;
}