Buf.subbuf在Perl 6中的奇怪行为

今天我安装了Rakudo Star 2012.07并尝试​​编写一个简单的Perl 6脚本:
#!/usr/bin/env perl6

use v6;
use LWP::Simple;

my $html = LWP::Simple.get('http://perl6.org');
say $html;

由于以下错误,它无法正常工作:

No such method 'get_string' for invocant of type 'String'
  in method decode at src/gen/CORE.setting:6766
  in method parse_response at lib/LWP/Simple.pm:244
  in method make_request at lib/LWP/Simple.pm:199
  in method request_shell at lib/LWP/Simple.pm:63
  in method get at lib/LWP/Simple.pm:28

第244行的LWP ::简单代码是:

my @header_lines = $resp.subbuf(
    0,$header_end_pos
).decode('ascii').split(/\r\n/);

奇怪的是,以下代码是可以的:

> Buf.new(1,2,3,4,5).decode('ascii')

而这一次失败了:

> Buf.new(1,5).subbuf(0,3).decode('ascii')
Method 'get_string' not found for invocant of class 'String'

你能解释一下,为什么会这样?据我所知,在两种情况下都会调用Buf.decode方法:

> Buf.new(1,3).isa('Buf')
True
> Buf.new(1,5).isa('Buf')
True

也许这是Rakudo Perl中的一个错误?或者也许subbuf是一个已弃用/未记录的方法?它不在doc.perl6.org上.在这种情况下应该使用哪种方法?

解决方法

这是Rakudo中的一个错误,已经在最新的开发版本中得到修复
$perl6 -e 'say Buf.new(1,3).decode("ascii")'|hexdump -C
00000000  01 02 03 0a                                       |....|

(我很确定该修复程序也是Rakudo 2012.08版本,基于编译器的Rakudo Star版本将在本周发布).

它没有被记录的原因是我专注于那些也在规范中的方法,因为它们有更高的生存机会.我希望尽快安排添加文档.

更新:绕过它,见http://doc.perl6.org/type/Buf#subbuf

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...