0
use Class::Struct;

struct(TradeId => [
        tradeIdScheme => '$',
        id => '$',
]);

struct(VersionedTradeId => [
        tradeId => 'TradeId',
        version => '$',
        effectiveDate => '@',
]);

我想在“VersionedTradeId”结构中创建一个“TradeId”数组。

4

1 回答 1

2

试试这个:http ://www.nntp.perl.org/group/perl.beginners/2007/09/msg95440.html

请参阅 Class::Struct 文档中的示例 1:

示例 1

给一个结构元素一个类类型,它也是一个结构是结构嵌套的方式。这里,Timeval 代表一个时间(秒和微秒),Rusage 有两个元素,每个元素都是 Timeval 类型。

use Class::Struct;
struct( Rusage => {
ru_utime => '@', # user time used
ru_stime => 'Timeval', # system time used
});
struct( Timeval => [
tv_secs => '$', # seconds
tv_usecs => '$', # microseconds
]);
# create an object:
my $t = Rusage->new(ru_utime=>[Timeval->new(), Timeval->new(), Timeval->new()], ru_stime=>Timeval->new());
# $t->ru_utime and $t->ru_stime are objects of type Timeval.
# set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
$t->ru_utime->tv_secs(100);
$t->ru_utime->tv_usecs(0);
$t->ru_stime->tv_secs(5);
$t->ru_stime->tv_usecs(0);
于 2012-06-21T20:18:49.467 回答