Filename | C:/tmp64ng/perl/lib/DirHandle.pm |
Statements | Executed 60 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 0s | 0s | BEGIN@31 | DirHandle::
1 | 1 | 1 | 0s | 0s | BEGIN@32 | DirHandle::
1 | 1 | 1 | 0s | 0s | BEGIN@50 | DirHandle::
6 | 2 | 1 | 0s | 0s | CORE:closedir (opcode) | DirHandle::
3 | 1 | 1 | 0s | 0s | CORE:open_dir (opcode) | DirHandle::
3 | 1 | 1 | 0s | 0s | CORE:readdir (opcode) | DirHandle::
3 | 1 | 1 | 0s | 0s | DESTROY | DirHandle::
3 | 1 | 1 | 0s | 0s | close | DirHandle::
3 | 1 | 1 | 0s | 0s | new | DirHandle::
3 | 1 | 1 | 0s | 0s | open | DirHandle::
3 | 1 | 1 | 0s | 0s | read | DirHandle::
0 | 0 | 0 | 0s | 0s | rewind | DirHandle::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DirHandle; | ||||
2 | |||||
3 | 1 | 0s | our $VERSION = '1.04'; | ||
4 | |||||
5 | =head1 NAME | ||||
6 | |||||
7 | DirHandle - supply object methods for directory handles | ||||
8 | |||||
9 | =head1 SYNOPSIS | ||||
10 | |||||
11 | use DirHandle; | ||||
12 | $d = DirHandle->new("."); | ||||
13 | if (defined $d) { | ||||
14 | while (defined($_ = $d->read)) { something($_); } | ||||
15 | $d->rewind; | ||||
16 | while (defined($_ = $d->read)) { something_else($_); } | ||||
17 | undef $d; | ||||
18 | } | ||||
19 | |||||
20 | =head1 DESCRIPTION | ||||
21 | |||||
22 | The C<DirHandle> method provide an alternative interface to the | ||||
23 | opendir(), closedir(), readdir(), and rewinddir() functions. | ||||
24 | |||||
25 | The only objective benefit to using C<DirHandle> is that it avoids | ||||
26 | namespace pollution by creating globs to hold directory handles. | ||||
27 | |||||
28 | =cut | ||||
29 | |||||
30 | 1 | 0s | require 5.000; | ||
31 | 2 | 0s | 2 | 0s | # spent 0s within DirHandle::BEGIN@31 which was called:
# once (0s+0s) by ExtUtils::MM_Unix::BEGIN@10 at line 31 # spent 0s making 1 call to DirHandle::BEGIN@31
# spent 0s making 1 call to Exporter::import |
32 | 2 | 0s | 2 | 0s | # spent 0s within DirHandle::BEGIN@32 which was called:
# once (0s+0s) by ExtUtils::MM_Unix::BEGIN@10 at line 32 # spent 0s making 1 call to DirHandle::BEGIN@32
# spent 0s making 1 call to Exporter::import |
33 | |||||
34 | # spent 0s within DirHandle::new which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by ExtUtils::MM_Unix::lsdir at line 2331 of ExtUtils/MM_Unix.pm, avg 0s/call | ||||
35 | 3 | 0s | @_ >= 1 && @_ <= 2 or croak 'usage: DirHandle->new( [DIRNAME] )'; | ||
36 | 3 | 0s | my $class = shift; | ||
37 | 3 | 0s | 3 | 0s | my $dh = gensym; # spent 0s making 3 calls to Symbol::gensym, avg 0s/call |
38 | 3 | 0s | if (@_) { | ||
39 | DirHandle::open($dh, $_[0]) | ||||
40 | or return undef; | ||||
41 | } | ||||
42 | 3 | 0s | bless $dh, $class; | ||
43 | } | ||||
44 | |||||
45 | # spent 0s within DirHandle::DESTROY which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by ExtUtils::MM_Unix::lsdir at line 1309 of ExtUtils/MM_Unix.pm, avg 0s/call | ||||
46 | 3 | 0s | my ($dh) = @_; | ||
47 | # Don't warn about already being closed as it may have been closed | ||||
48 | # correctly, or maybe never opened at all. | ||||
49 | 3 | 0s | local($., $@, $!, $^E, $?); | ||
50 | 2 | 0s | 2 | 0s | # spent 0s within DirHandle::BEGIN@50 which was called:
# once (0s+0s) by ExtUtils::MM_Unix::BEGIN@10 at line 50 # spent 0s making 1 call to DirHandle::BEGIN@50
# spent 0s making 1 call to warnings::unimport |
51 | 3 | 0s | 3 | 0s | closedir($dh); # spent 0s making 3 calls to DirHandle::CORE:closedir, avg 0s/call |
52 | } | ||||
53 | |||||
54 | # spent 0s within DirHandle::open which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by ExtUtils::MM_Unix::lsdir at line 2332 of ExtUtils/MM_Unix.pm, avg 0s/call | ||||
55 | 3 | 0s | @_ == 2 or croak 'usage: $dh->open(DIRNAME)'; | ||
56 | 3 | 0s | my ($dh, $dirname) = @_; | ||
57 | 3 | 0s | 3 | 0s | opendir($dh, $dirname); # spent 0s making 3 calls to DirHandle::CORE:open_dir, avg 0s/call |
58 | } | ||||
59 | |||||
60 | # spent 0s within DirHandle::close which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by ExtUtils::MM_Unix::lsdir at line 2334 of ExtUtils/MM_Unix.pm, avg 0s/call | ||||
61 | 3 | 0s | @_ == 1 or croak 'usage: $dh->close()'; | ||
62 | 3 | 0s | my ($dh) = @_; | ||
63 | 3 | 0s | 3 | 0s | closedir($dh); # spent 0s making 3 calls to DirHandle::CORE:closedir, avg 0s/call |
64 | } | ||||
65 | |||||
66 | # spent 0s within DirHandle::read which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by ExtUtils::MM_Unix::lsdir at line 2333 of ExtUtils/MM_Unix.pm, avg 0s/call | ||||
67 | 3 | 0s | @_ == 1 or croak 'usage: $dh->read()'; | ||
68 | 3 | 0s | my ($dh) = @_; | ||
69 | 3 | 0s | 3 | 0s | readdir($dh); # spent 0s making 3 calls to DirHandle::CORE:readdir, avg 0s/call |
70 | } | ||||
71 | |||||
72 | sub rewind { | ||||
73 | @_ == 1 or croak 'usage: $dh->rewind()'; | ||||
74 | my ($dh) = @_; | ||||
75 | rewinddir($dh); | ||||
76 | } | ||||
77 | |||||
78 | 1 | 0s | 1; | ||
sub DirHandle::CORE:closedir; # opcode | |||||
# spent 0s within DirHandle::CORE:open_dir which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by DirHandle::open at line 57, avg 0s/call | |||||
# spent 0s within DirHandle::CORE:readdir which was called 3 times, avg 0s/call:
# 3 times (0s+0s) by DirHandle::read at line 69, avg 0s/call |