Leser: 30
1 2 3 4 5 6 7 8
use Data::Dumper; local $Data::Dumper::Useqq = 1; for my $key (sort keys %main::) { my $sym = ${"main::"}{$key}; if (defined *{$sym}{SCALAR} and defined $$sym) { print Dumper [$key,$$sym]; } }'
2010-02-07T13:01:21 biancaLieber wäre mir $^O
print "OS: $^O\n";
1 2 3 4
use Devel::Symdump; my $obj = Devel::Symdump->new(@main::); my $string = $obj->as_string; print $string;
2010-02-07T14:34:02 pqmal sehn, ob es biancas gnade findet, ist ja schliesslich nicht im core ;-)
2010-02-07T14:39:40 pqfühl dich doch nicht immer gleich angesprochen ;-)
1 2 3 4 5 6 7 8 9 10 11 12
sub as_string { my $self = shift; my($type,@m); for $type (sort keys %{$self->{'AUTOLOAD'}}) { push @m, $type; push @m, "\t" . join "\n\t", map { s/([\000-\037\177])/ '^' . pack('c', ord($1) ^ 64) /eg; $_; } sort $self->_partdump(uc $type); } return join "\n", @m; }
s/([\000-\037\177])/ '^' . pack('c', ord($1) ^ 64) /eg;
2010-02-07T14:43:44 GwenDragonFaulpelz!
2010-02-07T14:56:05 reneeIn pq's Code fügst Du vor das print Dumper [$key,$$sym] einfach noch $key =~ s/([\000-\037\177])/ '$^' . pack('c', ord($1) ^ 64) /eg; ein... Ein wenig mehr "Spieltrieb" wäre manchmal nicht verkehrt ;-)
2010-02-07T14:56:55 betterworldWo wuerdest Du den Code auf einer Skala von 1 bis 10 der Schwierigkeitsstufen fuer Aufgaben mit "pack" einordnen?
2010-02-07T14:47:54 biancaOha, du willst internes Debugging deiner Programme machen, kennst aber bestimmte Sachen nicht? Das wird schwierig.Wo finde ich denn da die Stelle, wie ich an den Variableninhalt komme?
Sorry, das übersteigt meine Fähigkeiten.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl use strict; no strict 'refs'; use warnings; my $inhalt = ''; use Data::Dumper; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Sortkeys = \&dumper_filter; sub dumper_filter { my ($hash) = @_; return [(sort {lc $a cmp lc $b} keys %$hash)]; } $inhalt .= '<pre>'; for my $key (sort keys %main::) { my $sym = ${"main::"}{$key}; if (defined *{$sym}{SCALAR} and defined $$sym) { $inhalt .= Dumper [$key,$$sym]; } } $inhalt .= '</pre>'; print "$inhalt\n";
1
2
3
4
5
6
7
8
9
10
11
12
<pre>$VAR1 = [
"\b",
256
];
$VAR1 = [
"\17",
"MSWin32"
];
$VAR1 = [
"\27ARNING_BITS",
"\0\0\0\0\0\0\0\0\0\0\0\0"
];
2010-02-07T13:56:47 betterworldEdit: ah, pq hat das schon ausfuehrlicher geschrieben ;)
2010-02-07T13:59:57 pqoder halt was entsprechendes.
2010-02-07T14:08:48 pqmal scharf nachdenken.
$variablen_name =~ s/\17/^O/;
$name =~ s/([\x00-\x1f\x7f])/'^'.($1^'@')/eg;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use 5.010; use strict; use warnings; use Data::Dumper; for my $var (keys %main::) { my $name = $var; $name =~ s/([\x00-\x1f\x7f])/'^'.($1^'@')/eg; my $dumper = do { no strict qw/refs/; Data::Dumper->new([ $$var ], [ $name ]); }; print $dumper->Purity(1)->Useqq(1)->Dump(); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use 5.010; use strict; use warnings; use Data::Dumper; local $Data::Dumper::Purity = 1; local $Data::Dumper::Useqq = 1; for my $var (keys %main::) { my $glob = $main::{$var}; my $name = *$glob{NAME}; $name =~ s/([\x00-\x1f\x7f])/'^'.($1^'@')/eg; if ($name !~ /::$/) { do { my $ref = *$glob{SCALAR}; print Data::Dumper->Dump([ $$ref ], [ $name ]) if (defined $$ref); }; for my $part (qw/ARRAY HASH/) { my $ref = *$glob{$part}; print Data::Dumper->Dump([ $ref ], [ "*$name" ]) if (ref $ref); } } }
1 2 3 4
if (ref \$glob ne 'GLOB') { my $ref = ref \$glob; say "$glob: ref=$ref"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use strict; use warnings; use 5.10.0; for my $var (sort {lc $a cmp lc $b} keys %main::) { my $glob = $main::{$var}; if (ref \$glob ne 'GLOB') { my $ref = ref \$glob; say "$glob: ref=$ref"; say "$var: $glob: ref=$ref"; if (ref \$GLOB eq "SCALAR") { say $$glob } } }
QuoteGlobal symbol "$GLOB" requires explicit package name at test_perlvars.pl line 12.
Execution of test_perlvars.pl aborted due to compilation errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; use 5.10.0; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); for my $var (sort {lc $a cmp lc $b} keys %main::) { my $glob = $main::{$var}; if (ref \$glob ne 'GLOB') { my $ref = ref \$glob; say "$glob: ref=$ref"; say "$var: $glob: ref=$ref"; if (ref \$glob eq "SCALAR") { say $$glob } } }
QuoteSCALAR(0x2552e24): ref=REF
AZ_ERROR: SCALAR(0x2552e24): ref=REF
SCALAR(0x254cdb4): ref=REF
AZ_FORMAT_ERROR: SCALAR(0x254cdb4): ref=REF
SCALAR(0x44c474): ref=REF
AZ_IO_ERROR: SCALAR(0x44c474): ref=REF
SCALAR(0x2549464): ref=REF
AZ_OK: SCALAR(0x2549464): ref=REF
SCALAR(0x26d8bcc): ref=REF
AZ_STREAM_END: SCALAR(0x26d8bcc): ref=REF
SCALAR(0x26d9934): ref=REF
COMPRESSION_DEFLATED: SCALAR(0x26d9934): ref=REF
SCALAR(0x26d99f4): ref=REF
COMPRESSION_LEVEL_BEST_COMPRESSION: SCALAR(0x26d99f4): ref=REF
SCALAR(0x26d9994): ref=REF
COMPRESSION_LEVEL_DEFAULT: SCALAR(0x26d9994): ref=REF
SCALAR(0x26d99c4): ref=REF
COMPRESSION_LEVEL_FASTEST: SCALAR(0x26d99c4): ref=REF
SCALAR(0x26d9964): ref=REF
COMPRESSION_LEVEL_NONE: SCALAR(0x26d9964): ref=REF
SCALAR(0x26d9904): ref=REF
COMPRESSION_STORED: SCALAR(0x26d9904): ref=REF
SCALAR(0x254b8ac): ref=REF
FA_MSDOS: SCALAR(0x254b8ac): ref=REF
SCALAR(0x254b594): ref=REF
FA_UNIX: SCALAR(0x254b594): ref=REF
SCALAR(0x26d90f4): ref=REF
GPBF_DEFLATING_COMPRESSION_MASK: SCALAR(0x26d90f4): ref=REF
SCALAR(0x26d9064): ref=REF
GPBF_ENCRYPTED_MASK: SCALAR(0x26d9064): ref=REF
SCALAR(0x26d9144): ref=REF
GPBF_HAS_DATA_DESCRIPTOR_MASK: SCALAR(0x26d9144): ref=REF
SCALAR(0x26d9a84): ref=REF
IFA_BINARY_FILE: SCALAR(0x26d9a84): ref=REF
SCALAR(0x26d9a54): ref=REF
IFA_TEXT_FILE: SCALAR(0x26d9a54): ref=REF
SCALAR(0x26d9a24): ref=REF
IFA_TEXT_FILE_MASK: SCALAR(0x26d9a24): ref=REF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; use 5.10.0; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); use Data::Dumper; for my $var (sort {lc $a cmp lc $b} keys %main::) { my $glob = $main::{$var}; if (ref \$glob ne 'GLOB') { my $ref = ref \$glob; say "$glob: ref=$ref"; say "$var: $glob: ref=$ref"; if (ref \$glob eq "SCALAR") { say $$glob } } my $name = (ref \$glob ne 'GLOB' ? $var : *$glob{NAME}); $name =~ s/([\x00-\x1f\x7f])/'^'.($1^'@')/eg; if ($name !~ /::$/) { do { my $ref = *$glob{SCALAR}; print Data::Dumper->Dump([ $$ref ], [ $name ]) if (defined $$ref); }; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$main::test_variable = 23; sub test_sub; use constant test_constant => 23; sub test_sub2() { 23 } for my $var (sort keys %main::) { my $glob = $main::{$var}; my $ref = ref $glob; my $refref = ref \$glob; my $deref = $ref eq 'SCALAR' ? $$glob : '-'; say "var=$var glob=$glob ref=$ref refref=$refref deref=$deref"; }
1
2
3
4
var=test_constant glob=SCALAR(0x176bd08) ref=SCALAR refref=REF deref: 23
var=test_sub glob=-1 ref= refref=SCALAR deref: -
var=test_sub2 glob=*main::test_sub2 ref= refref=GLOB deref: -
var=test_variable glob=*main::test_variable ref= refref=GLOB deref: -
2014-10-19T18:34:26 pqist für bianca evtl. noch interessant