> The following was supposedly scribed by > Richard Clamp > on Thursday 06 May 2004 02:44 am:
>I already took a stab at solving it: >http://search.cpan.org/dist/File-Slurp-Tree/lib/File/Slurp/Tree.pm > >> In the event that it hasn't been solved, suggestions on the name and >> interface >> are just as welcome. > >I don't much like your disconnection between the file contents and >directory structure, I feel like I have to look in three places to get >a feel for the resulting nest of files. I'm starting from a table, rather than a nested hash, which seems to be the main difference between my spec and your module. However, the disconnect between the contents and the hash values is somewhat necessary. I could see a minor change to your code filling the bill. As a bigger example than the two farmers and a text string, let's say I've got 2000 files in a single directory and a table which holds some information about each of those files. e.g. the files are images and the table contains city, state, and date fields. I want to make copies of those images from the flat directory to the nested structure by state/city/date/<name>.jpg. Correct me if I'm wrong, but it seems from a quick test that a copy() using File::Copy is at least twice as fast as a read_file() followed by a write_file() using File::Slurp. I also may not want to actually copy the files. Maybe I want to symlink them. So, to use File::Slurp::Tree, I've got to first juggle my tabular data into the nested hash structure (seems that there is surely a module for this.) Then I would have to read all of the files' contents into the hash before calling spew_tree(). I'm fine with this setup, except for the speed hit vs a copy, and the inability to make symlinks. May I make changes to your Tree.pm version 1.22 to support subroutine refs in addition to strings? Additionally, can anyone suggest a good table->hash juggling module? It looks like Text::Column might be close Thanks, Eric
