F
freesoft12
Hi,
I am storing a large number of file paths into a hash table's keys (to
avoid duplicate paths) with well-known extensions
like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
the link is stored in the value field.
My questions are:
1) Is a custom data structure better than using a hash to store the
file paths?
2) I want to remove some of the files from the hash table that don't
match a regular expression (say I am only interested in *.cc files)
a) Is there a smart way to apply this regular expression on the
hash table? My current solution iterates over each item in the hash
table and then stores the keys that don't match the regex in a
separate list. I then iterate over that list and remove each key from
the hash table.
3) Does Perl allocate new memory if I were to copy the keys (paths) in
the hash table into a list or is a reference just copied?
Regards
John
I am storing a large number of file paths into a hash table's keys (to
avoid duplicate paths) with well-known extensions
like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
the link is stored in the value field.
My questions are:
1) Is a custom data structure better than using a hash to store the
file paths?
2) I want to remove some of the files from the hash table that don't
match a regular expression (say I am only interested in *.cc files)
a) Is there a smart way to apply this regular expression on the
hash table? My current solution iterates over each item in the hash
table and then stores the keys that don't match the regex in a
separate list. I then iterate over that list and remove each key from
the hash table.
3) Does Perl allocate new memory if I were to copy the keys (paths) in
the hash table into a list or is a reference just copied?
Regards
John