Commit | Line | Data |
a6f4eb0a |
1 | # Stash.pm -- show what stashes are loaded |
2 | # vishalb@hotmail.com |
3 | package B::Stash; |
4 | |
4755096e |
5 | =pod |
6 | |
7 | =head1 NAME |
8 | |
9 | B::Stash - show what stashes are loaded |
10 | |
11 | =cut |
12 | |
a6f4eb0a |
13 | BEGIN { %Seen = %INC } |
14 | |
7d30b5c4 |
15 | CHECK { |
a6f4eb0a |
16 | my @arr=scan($main::{"main::"}); |
ccc418af |
17 | @arr=map{s/\:\:$//;$_ eq "<none>"?():$_;} @arr; |
a6f4eb0a |
18 | print "-umain,-u", join (",-u",@arr) ,"\n"; |
19 | } |
20 | sub scan{ |
21 | my $start=shift; |
56eca212 |
22 | my $prefix=shift; |
23 | $prefix = '' unless defined $prefix; |
a6f4eb0a |
24 | my @return; |
25 | foreach my $key ( keys %{$start}){ |
56eca212 |
26 | # print $prefix,$key,"\n"; |
a6f4eb0a |
27 | if ($key =~ /::$/){ |
28 | unless ($start eq ${$start}{$key} or $key eq "B::" ){ |
56eca212 |
29 | push @return, $key unless omit($prefix.$key); |
30 | foreach my $subscan ( scan(${$start}{$key},$prefix.$key)){ |
a6f4eb0a |
31 | push @return, "$key".$subscan; |
32 | } |
33 | } |
34 | } |
35 | } |
36 | return @return; |
37 | } |
56eca212 |
38 | sub omit{ |
39 | my $module = shift; |
595f3c5f |
40 | my %omit=("DynaLoader::" => 1 , "XSLoader::" => 1, "CORE::" => 1 , |
56eca212 |
41 | "CORE::GLOBAL::" => 1, "UNIVERSAL::" => 1 ); |
42 | return 1 if $omit{$module}; |
43 | if ($module eq "IO::" or $module eq "IO::Handle::"){ |
44 | $module =~ s/::/\//g; |
45 | return 1 unless $INC{$module}; |
46 | } |
a6f4eb0a |
47 | |
56eca212 |
48 | return 0; |
49 | } |
50 | 1; |