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