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

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} = 'www.yoursite.com';

-Blake

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?

      -Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://202847]
help
Chatterbox?
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
Sections?
Information?
Find Nodes?
Leftovers?
    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.

    Notices?