Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: count multiple variables in a single array.by Marshall (Canon) |
on Feb 27, 2020 at 06:30 UTC ( [id://11113474]=note: print w/replies, xml ) | Need Help?? |
It is a bit hard for me to understand your complete specification. However, here is an attempt and some advice. I would not as a first thought change into the directory (chdir). Instead, I would run glob on the target directory from the current program directory. You have the full path information to do that. The problem with chdir is that you have to keep track of "where you are". In a longer program this can become problematic, especially in the case of some path error. You seem to have a file naming convention for files in this error directory with "userName-fileName.extn". I would not overly specify the .extns that could be in this directory. I allow any extension below (tiff, psd, whatever). I would of course not "hard code" the user names, which I think is part of your question. I use a HoA (Hash of Array) below. I made a few files underneath a test directory on my Windows machine, keyed to each discovered user name. A long time ago, I would have recommended against using glob() because there were 3 distinct versions and it wouldn't be clear which version you have. Now things have become more standardized and I think glob() is fine.
In Section
Seekers of Perl Wisdom
|
|