line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Creates db_util command line for DB_File management |
2
|
|
|
|
|
|
|
package DB_File::Utils; |
3
|
|
|
|
|
|
|
$DB_File::Utils::VERSION = '0.006'; |
4
|
2
|
|
|
2
|
|
77304
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
6
|
2
|
|
|
2
|
|
2873
|
use DB_File; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Fcntl; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use App::Cmd::Setup -app; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub global_opt_spec { |
12
|
|
|
|
|
|
|
return ( |
13
|
|
|
|
|
|
|
['u|utf8' => "Force UTF8 encoding/decoding on values."], |
14
|
|
|
|
|
|
|
['btree' => "Use BTree indexing method (default)"], |
15
|
|
|
|
|
|
|
['hash' => "Use Hash indexing method"], |
16
|
|
|
|
|
|
|
['recno' => "Use RecNo indexing method"], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub do_tie { |
21
|
|
|
|
|
|
|
my ($self, $file, $ops) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $mode = $ops->{_create_} ? (O_CREAT | O_RDWR) : O_RDWR; |
24
|
|
|
|
|
|
|
if ($ops->{recno}) { |
25
|
|
|
|
|
|
|
my @array; |
26
|
|
|
|
|
|
|
my $method = $DB_RECNO; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
tie @array, 'DB_File', $file, $mode, '0666', $method; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return \@array; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
|
|
|
|
|
|
my %hash; |
34
|
|
|
|
|
|
|
my $method = $ops->{hash} ? $DB_HASH : $DB_BTREE; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
tie %hash, 'DB_File', $file, $mode, '0666', $method; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return \%hash; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
DB_File::Utils - main module for db_util command line tool |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Please refer to C for detail on module usage. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SEE ALSO |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
db_util (3) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Alberto Simões C<< >> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Alberto Simões. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify |
68
|
|
|
|
|
|
|
it under the same terms as the Perl 5 programming language system itself. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |