Commit | Line | Data |
a6c6f671 |
1 | |
2 | require 5; |
3 | # Time-stamp: "2004-12-29 20:57:15 AST" |
4 | # Summary of, well, things. |
5 | |
6 | use Test; |
7 | BEGIN {plan tests => 2}; |
8 | ok 1; |
9 | |
10 | use Class::ISA (); |
11 | |
12 | #chdir "t" if -e "t"; |
13 | |
14 | { |
15 | my @out; |
16 | push @out, |
17 | "\n\nPerl v", |
18 | defined($^V) ? sprintf('%vd', $^V) : $], |
19 | " under $^O ", |
20 | (defined(&Win32::BuildNumber) and defined &Win32::BuildNumber()) |
21 | ? ("(Win32::BuildNumber ", &Win32::BuildNumber(), ")") : (), |
22 | (defined $MacPerl::Version) |
23 | ? ("(MacPerl version $MacPerl::Version)") : (), |
24 | "\n" |
25 | ; |
26 | |
27 | # Ugly code to walk the symbol tables: |
28 | my %v; |
29 | my @stack = (''); # start out in %:: |
30 | my $this; |
31 | my $count = 0; |
32 | my $pref; |
33 | while(@stack) { |
34 | $this = shift @stack; |
35 | die "Too many packages?" if ++$count > 1000; |
36 | next if exists $v{$this}; |
37 | next if $this eq 'main'; # %main:: is %:: |
38 | |
39 | #print "Peeking at $this => ${$this . '::VERSION'}\n"; |
40 | |
41 | if(defined ${$this . '::VERSION'} ) { |
42 | $v{$this} = ${$this . '::VERSION'} |
43 | } elsif( |
44 | defined *{$this . '::ISA'} or defined &{$this . '::import'} |
45 | or ($this ne '' and grep defined *{$_}{'CODE'}, values %{$this . "::"}) |
46 | # If it has an ISA, an import, or any subs... |
47 | ) { |
48 | # It's a class/module with no version. |
49 | $v{$this} = undef; |
50 | } else { |
51 | # It's probably an unpopulated package. |
52 | ## $v{$this} = '...'; |
53 | } |
54 | |
55 | $pref = length($this) ? "$this\::" : ''; |
56 | push @stack, map m/^(.+)::$/ ? "$pref$1" : (), keys %{$this . '::'}; |
57 | #print "Stack: @stack\n"; |
58 | } |
59 | push @out, " Modules in memory:\n"; |
60 | delete @v{'', '[none]'}; |
61 | foreach my $p (sort {lc($a) cmp lc($b)} keys %v) { |
62 | $indent = ' ' x (2 + ($p =~ tr/:/:/)); |
63 | push @out, ' ', $indent, $p, defined($v{$p}) ? " v$v{$p};\n" : ";\n"; |
64 | } |
65 | push @out, sprintf "[at %s (local) / %s (GMT)]\n", |
66 | scalar(gmtime), scalar(localtime); |
67 | my $x = join '', @out; |
68 | $x =~ s/^/#/mg; |
69 | print $x; |
70 | } |
71 | |
72 | print "# Running", |
73 | (chr(65) eq 'A') ? " in an ASCII world.\n" : " in a non-ASCII world.\n", |
74 | "#\n", |
75 | ; |
76 | |
77 | print "# \@INC:\n", map("# [$_]\n", @INC), "#\n#\n"; |
78 | |
79 | print "# \%INC:\n"; |
80 | foreach my $x (sort {lc($a) cmp lc($b)} keys %INC) { |
81 | print "# [$x] = [", $INC{$x} || '', "]\n"; |
82 | } |
83 | |
84 | ok 1; |
85 | |