line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# Hash::Extract |
3
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# Mastering programmed by YAMASHINA Hio |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright 2006 YAMASHINA Hio |
7
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
8
|
|
|
|
|
|
|
# $Id: /perl/Hash-Extract/lib/Hash/Extract.pm 580 2007-12-19T06:29:03.536065Z hio $ |
9
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
package Hash::Extract; |
11
|
4
|
|
|
4
|
|
128366
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
159
|
|
12
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
183
|
|
13
|
4
|
|
|
4
|
|
4472
|
use PadWalker qw(var_name); |
|
4
|
|
|
|
|
4612
|
|
|
4
|
|
|
|
|
584
|
|
14
|
4
|
|
|
4
|
|
29
|
use B; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
198
|
|
15
|
4
|
|
|
4
|
|
24
|
use base 'Exporter'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1281
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw(hash_extract); |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
19
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
# hash_extract(\%hash, my $var); |
28
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
29
|
|
|
|
|
|
|
sub hash_extract |
30
|
|
|
|
|
|
|
{ |
31
|
12
|
|
|
12
|
1
|
6475
|
my $hash = shift; |
32
|
12
|
|
|
|
|
24
|
my $i=0; |
33
|
12
|
|
|
|
|
28
|
foreach my $var (@_) |
34
|
|
|
|
|
|
|
{ |
35
|
12
|
|
|
|
|
53
|
my $name = var_name(1, \$var); |
36
|
12
|
100
|
|
|
|
73
|
$name or die "could not detect name of variable"; |
37
|
|
|
|
|
|
|
{ |
38
|
4
|
|
|
4
|
|
5040
|
local(%+); |
|
4
|
|
|
|
|
2312
|
|
|
4
|
|
|
|
|
655
|
|
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
25
|
|
39
|
7
|
|
|
|
|
44
|
$name =~ s/^\$//;# or die "argument is not scalar variable: $name"; |
40
|
|
|
|
|
|
|
} |
41
|
7
|
100
|
|
|
|
41
|
exists($hash->{$name}) or die "no such hash element: $name"; |
42
|
6
|
|
|
|
|
32
|
$var = $hash->{$name} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
# End of Module. |
48
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
49
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
50
|
|
|
|
|
|
|
# End of File. |
51
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
__END__ |