← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:10:03 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/Symbol.pm
StatementsExecuted 10 statements in 2.09ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11194µs94µsSymbol::::BEGIN@81Symbol::BEGIN@81
0000s0sSymbol::::delete_packageSymbol::delete_package
0000s0sSymbol::::geniosymSymbol::geniosym
0000s0sSymbol::::gensymSymbol::gensym
0000s0sSymbol::::qualifySymbol::qualify
0000s0sSymbol::::qualify_to_refSymbol::qualify_to_ref
0000s0sSymbol::::ungensymSymbol::ungensym
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Symbol;
2
3=head1 NAME
4
- -
8111.90ms194µs
# spent 94µs within Symbol::BEGIN@81 which was called: # once (94µs+0s) by IO::Handle::BEGIN@264 at line 81
BEGIN { require 5.005; }
# spent 94µs making 1 call to Symbol::BEGIN@81
82
8314µsrequire Exporter;
84136µs@ISA = qw(Exporter);
8516µs@EXPORT = qw(gensym ungensym qualify qualify_to_ref);
8615µs@EXPORT_OK = qw(delete_package geniosym);
87
8813µs$VERSION = '1.07';
89
9014µsmy $genpkg = "Symbol::";
91168µsmy $genseq = 0;
92
93134µsmy %global = map {$_ => 1} qw(ARGV ARGVOUT ENV INC SIG STDERR STDIN STDOUT);
94
95#
96# Note that we never _copy_ the glob; we just make a ref to it.
97# If we did copy it, then SVf_FAKE would be set on the copy, and
98# glob-specific behaviors (e.g. C<*$ref = \&func>) wouldn't work.
99#
100sub gensym () {
101 my $name = "GEN" . $genseq++;
102 my $ref = \*{$genpkg . $name};
103 delete $$genpkg{$name};
104 $ref;
105}
106
107sub geniosym () {
108 my $sym = gensym();
109 # force the IO slot to be filled
110 select(select $sym);
111 *$sym{IO};
112}
113
114sub ungensym ($) {}
115
116sub qualify ($;$) {
117 my ($name) = @_;
118 if (!ref($name) && index($name, '::') == -1 && index($name, "'") == -1) {
119 my $pkg;
120 # Global names: special character, "^xyz", or other.
121 if ($name =~ /^(([^a-z])|(\^[a-z_]+))\z/i || $global{$name}) {
122 # RGS 2001-11-05 : translate leading ^X to control-char
123 $name =~ s/^\^([a-z_])/'qq(\c'.$1.')'/eei;
124 $pkg = "main";
125 }
126 else {
127 $pkg = (@_ > 1) ? $_[1] : caller;
128 }
129 $name = $pkg . "::" . $name;
130 }
131 $name;
132}
133
134sub qualify_to_ref ($;$) {
135 return \*{ qualify $_[0], @_ > 1 ? $_[1] : caller };
136}
137
138#
139# of Safe.pm lineage
140#
141sub delete_package ($) {
142 my $pkg = shift;
143
144 # expand to full symbol table name if needed
145
146 unless ($pkg =~ /^main::.*::$/) {
147 $pkg = "main$pkg" if $pkg =~ /^::/;
148 $pkg = "main::$pkg" unless $pkg =~ /^main::/;
149 $pkg .= '::' unless $pkg =~ /::$/;
150 }
151
152 my($stem, $leaf) = $pkg =~ m/(.*::)(\w+::)$/;
153 my $stem_symtab = *{$stem}{HASH};
154 return unless defined $stem_symtab and exists $stem_symtab->{$leaf};
155
156
157 # free all the symbols in the package
158
159 my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH};
160 foreach my $name (keys %$leaf_symtab) {
161 undef *{$pkg . $name};
162 }
163
164 # delete the symbol table
165
166 %$leaf_symtab = ();
167 delete $stem_symtab->{$leaf};
168}
169
170128µs1;