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?
It was a bug in Rakudo, which has already been fixed in the newest development version
$ perl6 -e 'say Buf.new(1,2,3,4,5).subbuf(0,3).decode("ascii")'|hexdump -C
00000000 01 02 03 0a |....|
(I'm pretty sure the fix is also the Rakudo 2012.08 release, the Rakudo Star release based on the compiler will be out this week).
The reason it's not documented yet is that I've focused on those methods that are also in the spec, since they have a higher chance to survive. I'll hope to get around to adding the documentation soon though.
Update: got around to it, see http://doc.perl6.org/type/Buf#subbuf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With