| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Simple::Tuple; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
138084
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
15
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
71
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
178
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Simple::Tuple - Because tuples should be simple and simple to use! |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.01 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Tuples should simple to use and create so I created a simple tuple generator. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
To create a tuple just use Simple::Tuple and include a list of the name of the tuple and elements of the tuple. |
|
26
|
|
|
|
|
|
|
The Simple::Tuple will automatically create a class and getters and setters for the elements. |
|
27
|
|
|
|
|
|
|
example: |
|
28
|
|
|
|
|
|
|
use Simple::Tuple qw; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
will create a class called Pair with getters get_first, get_second and setters set_first, set_second. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
code snippet demostrating Simple::Tuple. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#! /usr/bin/env perl |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use warnings; |
|
37
|
|
|
|
|
|
|
use strict; |
|
38
|
|
|
|
|
|
|
use utf8; |
|
39
|
|
|
|
|
|
|
use feature qw; |
|
40
|
|
|
|
|
|
|
use Data::Dumper; |
|
41
|
|
|
|
|
|
|
use Simple::Tuple qw; |
|
42
|
|
|
|
|
|
|
use Simple::Tuple qw; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $p = Pair->new(1, 2,); |
|
45
|
|
|
|
|
|
|
my $n = Node->new(4, 5, 6,); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
say Dumper($p); |
|
48
|
|
|
|
|
|
|
say Dumper($n); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
say $p->get_first; |
|
51
|
|
|
|
|
|
|
say $p->get_second; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
say $n->get_left; |
|
54
|
|
|
|
|
|
|
say $n->get_data; |
|
55
|
|
|
|
|
|
|
say $n->get_right; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$p->set_first(11); |
|
58
|
|
|
|
|
|
|
$p->set_second(12); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$n->set_left(14); |
|
61
|
|
|
|
|
|
|
$n->set_data(15); |
|
62
|
|
|
|
|
|
|
$n->set_right(16); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
say $p->get_first; |
|
65
|
|
|
|
|
|
|
say $p->get_second; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
say $n->get_left; |
|
68
|
|
|
|
|
|
|
say $n->get_data; |
|
69
|
|
|
|
|
|
|
say $n->get_right; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
exit 0; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 EXPORT |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
No functions are exported. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 import |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub import { |
|
84
|
1
|
|
|
1
|
|
14
|
my (undef, $name, @funcs) = @_; |
|
85
|
1
|
50
|
|
|
|
16
|
return if !defined $name; |
|
86
|
1
|
|
|
1
|
|
8
|
no strict qw; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
433
|
|
|
87
|
0
|
|
|
|
|
|
*{"${name}::new"} = sub { |
|
88
|
0
|
|
|
0
|
|
|
my (undef, @v) = @_; |
|
89
|
0
|
|
|
|
|
|
my $c = @funcs; |
|
90
|
0
|
0
|
|
|
|
|
croak "Data structure($name) has $c elements(@funcs) but you entered(@v)" if @v != @funcs; |
|
91
|
0
|
|
|
|
|
|
bless \@v, $name |
|
92
|
0
|
|
|
|
|
|
}; |
|
93
|
0
|
|
|
|
|
|
while (my ($i, $f) = each @funcs) { |
|
94
|
0
|
|
|
0
|
|
|
*{"${name}::get_${f}"} = sub{my ($s) = @_; $s->[$i]}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
|
|
*{"${name}::set_${f}"} = sub{my ($s, $d) = @_; $s->[$i] = $d}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Gerard Gauthier, C<< >> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 BUGS |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
106
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
107
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SUPPORT |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
perldoc Simple::Tuple |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
You can also look for information at: |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * Search CPAN |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
L |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is Copyright (c) 2025 by Gerard Gauthier. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software, licensed under: |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; # End of Simple::Tuple |