水曜日, 2月 28, 2007

constant ARRAY

use constant ARRAY1 => ('hoge'=>'aaa','hoge2'=>'bbb','hoge3'=>'ccc');
%array2 = ARRAY1;
print $array2{'hoge'},"\n";

foreach my $key( keys %array2 ){
print "$key: $array2{$key}", "\n";
}

月曜日, 2月 26, 2007

sample "Class::Inspector" perl

#!/usr/local/bin/perl

use strict;use Class::Inspector;
package Test;
sub test_01 { print "test_01\n";}
sub test_02 { print "test_02\n";}

for my $m (sort grep /^test_/, @{Class::Inspector->methods('Test')}) {
Test->$m();
}

-result-

test_01
test_02

ラベル: