Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Tie::Filesystem - request for review

by erikharrison (Deacon)
on Jun 23, 2004 at 06:20 UTC ( #368952=note: print w/ replies, xml ) Need Help??


in reply to Re: Tie::Filesystem - request for review
in thread Tie::Filesystem - request for review

Similar. The difference is that Tie::Dir returns a stat for the value of each key. Tie::Filesystem returns another tied hash for directories. I haven't decided what to return in for files yet.

use Tie::Filesytem; tie %root, Tie::Filesystem; print "Perl Found!" if exists $root{usr}->{bin}{perl};
Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


Comment on Re^2: Tie::Filesystem - request for review
Download Code
Re^3: Tie::Filesystem - request for review
by jepri (Parson) on Jun 23, 2004 at 06:53 UTC
    You mean like a filehandle or a scalar? I'd like to be able to open a data file with $root->{tmp}->{data.txt}.

    The idea of just reading and writing a file by assigning to a hash is very tempting, although getting a filehandle back might be better if it has to be passed to other functions.

    If you add either, I could see myself using it heavily, not the least because it would allow me to transparently fake a filesystem. VFS perl style. Woo hoo!

    ___________________
    Jeremy
    I didn't believe in evil until I dated it.

      Actually, building a simple perl VFS on top of this was a plan from the begining

      The reason that, say, $fs{etc}->{passwd} == '/etc/passwd' currently is because the downside of this interfece is that it is difficult to get the full pathname without walking back up the tree. Having the full path name gives the programmer flexibilty and keeps the thing light.

      What about this: an optional argument to the tie is a closure. This closure takes the full path to a file, and returns some arbitrary scalar - a filehandle ref, the leafname, a Tie::File array ref, whatever. How's that sound?

      Cheers,
      Erik

      Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet

        I'm not quite sure of the what you are suggesting there, but it does sound good. Having a unique key for each file is nice, but I'm tempted to suggest that I can build that very easily as I do my hash traversal. In use, I'm likely to get the hashref for the directory, and then iterate over the files or something like that.

        The obvious solution would be an object, but I'm not found of objects in this sort of work. They aren't particularily perlish. I'm not exactly sure what would be though.

        I look forwards to your publishing your code - I have a use for it so I can guarantee you a user right away.

        ___________________
        Jeremy
        I didn't believe in evil until I dated it.

Re^3: Tie::Filesystem - request for review
by trialmonkey (Hermit) on Jun 27, 2004 at 21:07 UTC
    I have some XML data that's hierarcically orgainzed and stored within the filesystem. Each data file is relatively small. Slurping and writing the data back out using a hash assignment would make for a nice interface to my data.

    A feature that allowed me to return a list of files filtered by access or change time would be also be useful.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2014-08-01 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (27 votes), past polls