Today I installed Rakudo Star 2012.07 and tryed to write a simple Perl 6 script:
#!/usr/bin/env perl6
use v6;
use LWP::Simple;
my $html = LWP::Simple.get('http://perl6.org');
say $html;
It doesn't work because of the following error:
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
Code of LWP::Simple on line 244 is:
my @header_lines = $resp.subbuf(
0, $header_end_pos
).decode('ascii').split(/\r\n/);
The strange thing is that the following code is OK:
> Buf.new(1,2,3,4,5).decode('ascii')
while this one fails:
> Buf.new(1,2,3,4,5).subbuf(0,3).decode('ascii')
Method 'get_string' not found for invocant of class 'String'
Could you explain me please, why it happens? As far as I can see, in both cases Buf.decode method is called:
> Buf.new(1,2,3,4,5).subbuf(0,3).isa('Buf')
True
> Buf.new(1,2,3,4,5).isa('Buf')
True
Perhaps it's a bug in Rakudo Perl? Or maybe subbuf is a deprecated/undocumented method? It's not present on doc.perl6.org. In this case which method should be used?