Dzisiaj zainstalowałem Rakudo Gwiazdę 2012.07 i tryed napisać prosty skrypt Perl 6:Dziwne zachowanie Buf.subbuf w Perl 6
#!/usr/bin/env perl6
use v6;
use LWP::Simple;
my $html = LWP::Simple.get('http://perl6.org');
say $html;
To nie działa z powodu następującego błędu:
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
Kodeks LWP :: Simple na linii 244 jest:
my @header_lines = $resp.subbuf(
0, $header_end_pos
).decode('ascii').split(/\r\n/);
Najdziwniejsze jest to, że poniższy kod jest OK:
> Buf.new(1,2,3,4,5).decode('ascii')
podczas gdy jeden z nich zawiedzie:
> Buf.new(1,2,3,4,5).subbuf(0,3).decode('ascii')
Method 'get_string' not found for invocant of class 'String'
mógłbyś mi wyjaśnić, proszę, dlaczego tak się dzieje? O ile widzę, w obu przypadkach metoda Buf.decode nazywa się:
> Buf.new(1,2,3,4,5).subbuf(0,3).isa('Buf')
True
> Buf.new(1,2,3,4,5).isa('Buf')
True
Być może jest to błąd w Rakudo Perl? A może subbuf jest przestarzałą/nieudokumentowaną metodą? Nie ma go na doc.perl6.org. W takim przypadku jakiej metody należy użyć?
Może chcesz zapytać że na IRC, kanał # perl6. Zobacz: http://irclog.perlgeek.de/perl6/today –