| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # ---------------------------------------------------------------------------- | 
| 2 |  |  |  |  |  |  | # "THE BEER-WARE LICENSE" (Revision 42) | 
| 3 |  |  |  |  |  |  | #  wrote this file.  As long as you retain this notice you | 
| 4 |  |  |  |  |  |  | # can do whatever you want with this stuff. If we meet some day, and you think | 
| 5 |  |  |  |  |  |  | # this stuff is worth it, you can buy me a beer in return.   Anton Berezin | 
| 6 |  |  |  |  |  |  | # ---------------------------------------------------------------------------- | 
| 7 |  |  |  |  |  |  | # | 
| 8 |  |  |  |  |  |  | # $Id: Dirfd.pm,v 1.1.1.1 2001/11/21 17:30:15 tobez Exp $ | 
| 9 |  |  |  |  |  |  | # | 
| 10 |  |  |  |  |  |  | package IO::Dir::Dirfd; | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 1 |  |  | 1 |  | 2993 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 47 |  | 
| 13 | 1 |  |  | 1 |  | 6 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 159 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | require Exporter; | 
| 16 |  |  |  |  |  |  | require DynaLoader; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | @ISA = qw(Exporter DynaLoader); | 
| 19 |  |  |  |  |  |  | @EXPORT = qw(dirfd); | 
| 20 |  |  |  |  |  |  | @EXPORT_OK = qw(fileno); | 
| 21 |  |  |  |  |  |  | $VERSION = '0.01'; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub dirfd(*); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | bootstrap IO::Dir::Dirfd $VERSION; | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub fileno(*) | 
| 28 |  |  |  |  |  |  | { | 
| 29 | 1 |  |  | 1 |  | 6 | no strict "refs"; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 135 |  | 
| 30 | 20 |  |  | 20 | 0 | 45797 | my $no; | 
| 31 | 20 |  |  |  |  | 26 | eval { $no = CORE::fileno($_[0]) }; | 
|  | 20 |  |  |  |  | 68 |  | 
| 32 | 20 | 100 |  |  |  | 53 | return $no if defined $no; | 
| 33 | 17 |  |  |  |  | 24 | my $arg = $_[0]; | 
| 34 | 17 |  |  |  |  | 25 | $! = 0; | 
| 35 | 17 | 100 | 66 |  |  | 66 | unless (ref($arg) || $arg =~ /(^\*)|(::)/) { | 
| 36 | 3 |  | 50 |  |  | 10 | my $caller = caller || 'main'; | 
| 37 | 3 |  |  |  |  | 8 | $arg = "${caller}::$arg"; | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 17 |  |  |  |  | 46 | $no = dirfd($arg); | 
| 40 | 1 |  |  | 1 |  | 5 | use strict "refs"; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 56 |  | 
| 41 | 16 |  |  |  |  | 41 | $no; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | 1; | 
| 45 |  |  |  |  |  |  | __END__ |