本当にチラ裏なんだけど、やっぱりよく忘れるので貼っておく。
code
#!/usr/bin/perl
use Data::Dumper;
use IO::Handle;
my $a = 'aaa';
${ $a } = 'hogehoge';
@{ $a } = qw/ foo bar baz / ;
%{ $a } = ( name => 'test', age => 21 );
*{ $a } = sub { return 'pooh!' };
open $a, './pee.pl';
print Dumper { package => *{ $a }{ PACKAGE } };
print Dumper { name => *{ $a }{ NAME } };
print Dumper { io => *{ $a }{ IO } };
print Dumper { format => *{ $a }{ FORMAT } };
print Dumper { glob => *{ $a }{ GLOB } };
print Dumper { scalar => *{ $a }{ SCALAR } };
print Dumper { array => *{ $a }{ ARRAY } };
print Dumper { hash => *{ $a }{ HASH } };
print Dumper { code => *{ $a }{ CODE } };
print Dumper $a->();
print Dumper [ *{ $a }{ IO }->getline ];
close $a;
sub doooo {
3;
}
for my $key ( keys %main:: ) {
print Dumper $key if *{ $main::{$key} }{ CODE };
}
結果
$VAR1 = {
'package' => 'main'
};
$VAR1 = {
'name' => 'aaa'
};
cannot handle ref type 15 at /usr/lib/perl/5.8/Data/Dumper.pm line 179.
$VAR1 = {
'io' => bless( , 'IO::Handle' )
};
$VAR1 = {
'format' => undef
};
$VAR1 = {
'glob' => \*::aaa
};
$VAR1 = {
'scalar' => \'hogehoge'
};
$VAR1 = {
'array' => [
'foo',
'bar',
'baz'
]
};
$VAR1 = {
'hash' => {
'name' => 'test',
'age' => 21
}
};
$VAR1 = {
'code' => sub { "DUMMY" }
};
$VAR1 = 'pooh!';
$VAR1 = [
'#!/usr/bin/perl
'
];
$VAR1 = 'doooo';
$VAR1 = 'aaa';
$VAR1 = 'Dumper';
0 件のコメント:
コメントを投稿