- 论坛徽章:
- 95
|
原帖由 pugs 于 2008-12-27 19:53 发表 ![]()
perl 5解释器是基于虚拟机的吗?
是的。
可以用 Perl 自带的一些模块,例如 B::*, 如
- $ perl -MO=Terse t.pl
- LISTOP (0x8225f28) leave [1]
- OP (0x8193070) enter
- COP (0x8225ef0) nextstate
- LISTOP (0x819ee90) print
- OP (0x82851e8) pushmark
- UNOP (0x819ee70) entersub [2]
- UNOP (0x819ee50) null [142]
- OP (0x819a280) pushmark
- SVOP (0x819ee30) const [4] IV (0x81976a0) 10
- UNOP (0x819a298) null [17]
- PADOP (0x819a1f0) gv GV (0x8227da8) *factorial
- SVOP (0x82851c8) const [5] PV (0x8227d88) "\n"
- t.pl syntax OK
复制代码
或按照执行顺序
- perl -MO=Terse,exec t.pl
- OP (0x8193078) enter
- COP (0x819a548) nextstate
- OP (0x819d780) pushmark
- OP (0x820cf08) pushmark
- SVOP (0x819a2b8) const [4] IV (0x81976a8) 10
- PADOP (0x820cf20) gv GV (0x8227da0) *factorial
- UNOP (0x819a028) entersub [2]
- SVOP (0x819d798) const [5] PV (0x8227d80) "\n"
- LISTOP (0x819d7b8) print
- LISTOP (0x819a580) leave [1]
- t.pl syntax OK
复制代码
- $ cat t.pl
- use strict;
- use warnings;
- print factorial(10), "\n";
- sub factorial {
- my $n = shift;
- return 1 if $n <= 1;
-
- return $n * factorial(--$n);
- }
复制代码
参见 http://www.faqs.org/docs/perl5int/
[ 本帖最后由 MMMIX 于 2008-12-27 21:07 编辑 ] |
|