Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: How to map a directory tree to a perl hash tree

by Rudif (Hermit)
on Mar 12, 2001 at 02:15 UTC ( [id://63672]=note: print w/replies, xml ) Need Help??


in reply to Re: How to map a directory tree to a perl hash tree
in thread How to map a directory tree to a perl hash tree

May be it would be suitable to use tied hash(see e.g. Tie::Dir)?
Tie::Dir handles files in one directory. It should be posible to write a Tie::DirTree along similar lines.

At times I used Tie modules (Win32::OLE, Tie::Registry), but at this stage I don't have a feel for the advantages of a Tie module relative to a plain module. I suppose a Tie module adds syntactic convenience. Can you or any other Monk elaborate on this?

Do you really need to load all the directory tree into the memory before scanning?

It depends on what I want to do. A simple job (e.g. count the number of .html files and compute their total size) can be done simply in the find's wanted subroutine.
For more elaborate jobs it might be better to first extract the relevant directory and file information into a Perl structure and then work on that structure, for example:
  • generate a graphical representation of the directory tree for a browser (javascript, html, chm)
  • compare the perl/html tree with perl/lib and per/site/lib trees to find .pm and .pod files that have no corresponding .html file, and make that file
Rudif
  • Comment on Re: Re: How to map a directory tree to a perl hash tree

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63672]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-19 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found