我无法使用Inline C将arrayrefs传递给C函数.我想请一些帮助.
首先,为了证明我可以让Inline C工作,我会将标量值传递给C函数:
#!/usr/bin/perl -I.
#
# try1.pl
#
use Inline C;
my $c = 3.8;
foo( $c );
__END__
__C__
void foo( double c )
{
printf( "C = %f\n", c );
}
Run Code Online (Sandbox Code Playgroud)
并运行它:
% ./try1.pl
C = 3.800000
Run Code Online (Sandbox Code Playgroud)
现在做同样的事情,但使用arrayref:
#!/usr/bin/perl -I.
#
# try2.pl
#
use Inline C;
my @abc = (1.9, 2.3, 3.8);
foo( \@abc );
__END__
__C__
void foo( double *abc )
{
printf( "C = %f\n", abc[2] );
}
Run Code Online (Sandbox Code Playgroud)
运行:
% ./try2.pl
Undefined subroutine …
Run Code Online (Sandbox Code Playgroud) 我丢失了 ISODate 对象的 MongoDb 接口的纳秒数。当我在 perl 中读取它们时,所有纳秒都设置为零。
首先是我的环境:
MongoDB version: 1.8.2
perl v5.12.4
MongoDB perl module version: 0.701.4
Run Code Online (Sandbox Code Playgroud)
我有一个 Mongo DB,其 rtcTime 编码为 ISODate,如下所示:
"rtcTime" : ISODate("2013-05-13T18:54:55.918Z")
Run Code Online (Sandbox Code Playgroud)
提取 rtcTime 的代码如下所示:
my @results = $db->get_collection( 'timings' )->find( )->all();
foreach my $record ( @results )
{
print $record->{rtcTime}->nanoseconds()."\n";
}
Run Code Online (Sandbox Code Playgroud)
输出全为 0。
要完全重现该问题,请在 MongoDB 数据库中创建一个具有任意(非零)hires_epoch 值的 ISODate 对象。然后尝试使用 MongoDB / DateTime / DateTime::Format::ISO8061 模块来提取任何类型的员工时间数据。
问:为什么我无法从 MongoDB ISODate 数据中获取毫秒、微秒或纳秒?