line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1805
|
use 5.12.0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
package fewer; |
4
|
|
|
|
|
|
|
# ABSTRACT: use fewer units of a countable resource |
5
|
|
|
|
|
|
|
$fewer::VERSION = '0.203'; |
6
|
1
|
|
|
1
|
|
4
|
use less 0.03 (); |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
15
|
|
7
|
1
|
|
|
1
|
|
787
|
use parent 'less'; |
|
1
|
|
|
|
|
302
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
0
|
3724
|
sub stash_name { 'less' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=pod |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=encoding UTF-8 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
fewer - use fewer units of a countable resource |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 VERSION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
version 0.203 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use fewer 'top level namespaces'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
As of perl5 version 10, the long-useless pragma L became a usable tool |
32
|
|
|
|
|
|
|
for indicating that less I could be used. For example, the user |
33
|
|
|
|
|
|
|
could specify that less memory should be used, and other libraries could then |
34
|
|
|
|
|
|
|
choose between multiple algorithms based on that choice. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
In the user's program: |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use less 'memory'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $result = Analyzer->analyze( $large_data_set ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
In the library: |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub analyze { |
45
|
|
|
|
|
|
|
my ($self, $data) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $cache = less->of('memory') ? 'disk' : 'ram'; |
48
|
|
|
|
|
|
|
my $method = "analyze_with_${cache}_cache"; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self->$method($data); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This allowed for an explosion of highly adaptive implementions, accounting for |
54
|
|
|
|
|
|
|
a complex matrix of "less" interactions. Unfortunately, with the introduction |
55
|
|
|
|
|
|
|
of new strictures in perl5 version 18, the following code will stop working: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use strict 'English'; |
58
|
|
|
|
|
|
|
use less 'filehandles'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
To clarify the matter for our foreign readership, "less" is used for things |
61
|
|
|
|
|
|
|
which are uncounted, while "fewer" is used for counted resources. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This library corrects this error by allowing the user to write: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
use fewer 'filehandles'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Then, both of the following conditions will be true: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if ( less->of('filehandles') ) { ... } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if ( fewer->of('filehandles') ) { ... } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Ricardo SIGNES |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Ricardo SIGNES. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
82
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |