in reply to Re^4: File:Find pattern match question
in thread File:Find pattern match question
"Hi Ken I tried your example but it wouldn't output anything."
The technique I showed should work fine. In his response below, Athanasius has highlighted the issue with your original premise (i.e. parent vs. current directory). You can still use the technique I provided, you'll just need to work it into the code fix he's shown.
"If I removed the pattern match string it does work but I'm not sure what it is printing out - the directory listing seems random."
Hashes are unordered: keys %hash_name will return a list of keys in an apparently random order. If you're interested, see the "Hash Algorithm" section of "perlsec: Algorithmic Complexity Attacks" for more details.
sort may provide the ordering you want. If not, you may want to consider an array, or perhaps a more complex data structure, instead of a hash, to store your data. See "perldsc - Perl Data Structures Cookbook".
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: File:Find pattern match question
by RockE (Novice) on Nov 02, 2013 at 12:36 UTC | |
by kcott (Archbishop) on Nov 03, 2013 at 05:07 UTC | |
by RockE (Novice) on Nov 03, 2013 at 11:52 UTC | |
by kcott (Archbishop) on Nov 13, 2013 at 16:44 UTC |