in reply to Determine if item is last one
Given the fact that a directory handle is a typeglob (approximately) and recursion is always with us, I find the best way to do readdirs is "all at once", this reduces the chance that I will have two directory handles with the same name interfere with each other.
{ my(@files,$file); local(*DIR); opendir(DIR,$dir_name); @files = readdir(DIR); closedir(DIR); foreach $file (@files) { next if(/^\.\.?/); ... } }
If you adopt this strategy then your question becomes "how do I find out if this item is last one on the list", and therefore very easy to answer.
|
|---|