Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

by jepri (Parson)
on Jun 23, 2004 at 06:53 UTC ( #368956=note: print w/replies, xml ) Need Help??

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

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!

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

  • Comment on Re^3: Tie::Filesystem - request for review

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

    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?


    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.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-02-01 02:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found