line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package your; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.004; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
28588
|
use strict qw(vars subs); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
419
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.00'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
your - Perl pragma to declare use of other package's variables |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use your qw($Foo::bar @Moo::you %This::that); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
You should use variables from other packages with care, but as long as |
20
|
|
|
|
|
|
|
you're going to, it doesn't hurt to predeclare it. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Currently, if you use another package's variables and only use it |
23
|
|
|
|
|
|
|
once, Perl will throw a "variable used only once" warning. vars.pm |
24
|
|
|
|
|
|
|
won't allow you to declare other package's variables, and there are |
25
|
|
|
|
|
|
|
various hack to get around that. This package lets you declare "Yes, |
26
|
|
|
|
|
|
|
I am going to use someone else's variables!" |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Foo; |
29
|
|
|
|
|
|
|
use your qw($Foo::magic); |
30
|
|
|
|
|
|
|
print $Foo::magic; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub import { |
36
|
2
|
|
|
2
|
|
1781
|
my $caller = caller; |
37
|
2
|
|
|
|
|
5
|
my($class, @imports) = @_; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
4
|
foreach my $sym (@imports) { |
40
|
3
|
|
|
|
|
25
|
my($type, $name) = unpack('a1a*', $sym); |
41
|
3
|
100
|
|
|
|
12
|
unless( $name =~ /::/ ) { |
42
|
1
|
|
|
|
|
7
|
require Carp; |
43
|
1
|
|
|
|
|
167
|
Carp::croak("Can only declare other package's variables"); |
44
|
|
|
|
|
|
|
} |
45
|
2
|
50
|
|
|
|
6
|
if( $name =~ tr/A-Za-z_0-9://c ) { |
46
|
0
|
0
|
|
|
|
0
|
if( $sym =~ /^\w+[\[{].*[\]}]$/ ) { |
|
|
0
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
require Carp; |
48
|
0
|
|
|
|
|
0
|
Carp::croak("Can't declare individual elements of a hash or array"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ( $^H &= strict::bits('vars') ) { |
51
|
0
|
|
|
|
|
0
|
require Carp; |
52
|
0
|
|
|
|
|
0
|
Carp::croak("'$sym' is not a valid variable name under strict vars"); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
*$name = |
56
|
|
|
|
|
|
|
( $type eq "\$" ? \$$name |
57
|
|
|
|
|
|
|
: $type eq "\@" ? \@$name |
58
|
|
|
|
|
|
|
: $type eq "\%" ? \%$name |
59
|
|
|
|
|
|
|
: $type eq "\*" ? \*$name |
60
|
|
|
|
|
|
|
: $type eq "\&" ? \&$name |
61
|
2
|
0
|
|
|
|
437
|
: do { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
require Carp; |
63
|
0
|
|
|
|
|
|
Carp::croak("'$sym' is not a valid variable name"); |
64
|
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Michael G Schwern |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright 2001, 2007 by Michael G Schwern Eschwern@pobox.comE. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
78
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
See F |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L, L, L, L |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |