perl 语言表达C语言里的结构体?

perl 语言要怎样表达C语言里的结构体, 请以下代码为例 用perl 语言表达。
struct center_point
{
float x,y,dx,dy;
}
struct center_point cp[];
struct drc_cp[];

第1个回答  2013-01-15
use Clone qw/clone/;
use Data::Dumper;

$center_point = {
x => undef, y => undef,
dx => undef, dy => undef,
};
$cp = clone $center_point;

$center_point -> {x} = 1; $center_point -> {y} = 2;
$cp -> {x} = "a"; $cp -> {y} = "b";

print Dumper $center_point;
print Dumper $cp;本回答被网友采纳
第2个回答  2013-01-15
$a=1.2;
$b=1.3;
$c=1.2;
$str=pack('ffff',$a,$b,$c,$d);
@d=unpack('ffff',$str);
print "@d";
相似回答