in reply to Re: Holding site variables
in thread Holding site variables
It might not work every time, but it works most of the times:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Data::Dumper; local $Data::Dumper::Deparse = 1; sub secret { 'Just Another Perl Hacker,' } for my $symbol (keys %main::) { my $def = do { no strict; Dumper(${'main::'}{$symbol}) }; say "$symbol => $def" if $def =~ /sub/; }
Update: Or, instead of using a regex to identify subs:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Data::Dumper; local $Data::Dumper::Deparse = 1; sub secret { 'Just Another Perl Hacker,' } for my $symbol (keys %main::) { my $def = do { no strict; *{"main::$symbol"}{CODE} }; say "$symbol => ", Dumper $def if $def; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Holding site variables
by bliako (Abbot) on Mar 22, 2024 at 09:31 UTC |