请问在perl中如何对小数进行取整?

请问在perl中如何对小数进行取整?

#!/usr/bin/perl -w
use strict;
my $my_dir = "/tmp";
system `vmstat 1 2 > $my_dir/vmstat.out`;
chomp (my $free_mem_kb = `tail -1 $my_dir/vmstat.out | awk '{print \$5}'`);
print "free_mem_kb is $free_mem_kb \n";
#此处要取整
my $free_mem_mb = $free_mem_kb / 1024;
print "\$free_mem_mb is $free_mem_mb \n";
printf "\$free_mem_mb is %d",$free_mem_mb;

该段的结果为:
$free_mem_mb is 742.82421875
$free_mem_mb is 742

虽然我知道可以用printf来将变量$free_mem_mb打印成整数格式,但是我希望可以直接将$free_mem_mb进行取整,以方便进行一些加和减的操作。

请问可以有方法做到吗?
类似于ORACLE的TRUNC函数一样:
SQL> SELECT TRUNC(100.99) FROM DUAL;
TRUNC(100.99)
-------------
          100

谢谢!

我希望可以有类似下面的语法:
my $free_mem_mb = 进行取整($free_mem_kb / 1024);




int(100.99)
谢谢!
我也觉得是int()
刚才测试了一下,提示出错:

bash-3.00# ./92
Undefined subroutine &main::init called at ./92 line 4.
bash-3.00# more 92
#!/usr/bin/perl -w
use strict;
my $my_number = 100.99;
my $my_init = init($my_number);
print "\$my_number is $my_number \n";
print "\$my_init is $my_init \n";


QUOTE:
原帖由 jjqing 于 2008-8-23 09:27 发表
刚才测试了一下,提示出错:

bash-3.00# ./92
Undefined subroutine &main::init called at ./92 line 4.
bash-3.00# more 92
#!/usr/bin/perl -w
use strict;
my $my_number = 100.99;
my $my_init = ...

不好意思,刚才打错一个字,int打成了init,现在改过来,就可以了,谢谢!
这种bug最恶心了。呵呵,不过用好点的ide,int会高亮,而init不会。
int,记住了,小数取整,应该是强制类型转化
很多语言都有这类函数啊。
你最近去哪混了? 怎么积分一下子就那么多了 ?