Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Storing metadata with file handles

by blakem (Monsignor)
on Oct 04, 2002 at 18:43 UTC ( #202847=note: print w/replies, xml ) Need Help??

in reply to Storing metadata with file handles

Perhaps you should use the file descriptor number as a lookup key:
my %domain; my $filenum = fileno($fh); $domain{$filenum} = '';


Replies are listed 'Best First'.
Re: Re: Storing metadata with file handles
by gomez18 (Sexton) on Oct 04, 2002 at 18:54 UTC
    That's perfect. Exactly what I was looking for.

    An 8 bit man in a 32 bit world.

      And if you want to get really evil (read nonportable, and somewhat unreliable) you can sometimes associate the filenum back to a filename. Warning: this code is fragile, won't always work, and will only work on unix.
      my $fileno = fileno($fh); my $filename = readlink("/dev/fd/" . $fileno);
      See: Re: Re: Can you delete a file by descriptor?


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2019-08-19 21:08 GMT
Find Nodes?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?

    Results (141 votes). Check out past polls.