Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Tie::Filesystem - request for review

by BrowserUk (Patriarch)
on Jun 23, 2004 at 06:02 UTC ( #368947=note: print w/replies, xml ) Need Help??


in reply to Tie::Filesystem - request for review

On the surface, this looks vaguely similar to Tie::Dir?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: Tie::Filesystem - request for review
by erikharrison (Deacon) on Jun 23, 2004 at 06:20 UTC

    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

      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 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://368947]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-02-08 04:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?