Re-integrate mainline
[p5sagit/p5-mst-13.2.git] / ext / B / B / Stash.pm
CommitLineData
a6f4eb0a 1# Stash.pm -- show what stashes are loaded
2# vishalb@hotmail.com
3package B::Stash;
4
5BEGIN { %Seen = %INC }
6
7END {
8 my @arr=scan($main::{"main::"});
9 @arr=map{s/\:\:$//;$_;} @arr;
10 print "-umain,-u", join (",-u",@arr) ,"\n";
11}
12sub scan{
13 my $start=shift;
56eca212 14 my $prefix=shift;
15 $prefix = '' unless defined $prefix;
a6f4eb0a 16 my @return;
17 foreach my $key ( keys %{$start}){
56eca212 18# print $prefix,$key,"\n";
a6f4eb0a 19 if ($key =~ /::$/){
20 unless ($start eq ${$start}{$key} or $key eq "B::" ){
56eca212 21 push @return, $key unless omit($prefix.$key);
22 foreach my $subscan ( scan(${$start}{$key},$prefix.$key)){
a6f4eb0a 23 push @return, "$key".$subscan;
24 }
25 }
26 }
27 }
28 return @return;
29}
56eca212 30sub omit{
31 my $module = shift;
32 my %omit=("DynaLoader::" => 1 , "CORE::" => 1 ,
33 "CORE::GLOBAL::" => 1, "UNIVERSAL::" => 1 );
34 return 1 if $omit{$module};
35 if ($module eq "IO::" or $module eq "IO::Handle::"){
36 $module =~ s/::/\//g;
37 return 1 unless $INC{$module};
38 }
a6f4eb0a 39
56eca212 40 return 0;
41}
421;