#!/usr/bin/perl -w use 5.011; # use utf8; commenting out ## first time for this use utf8::all; use Encode; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Cookies; use JSON; use Data::Dump; use Data::Dumper; binmode STDOUT, ":utf8"; my $browser = LWP::UserAgent->new; # they ask to use descriptive user-agent - not LWP defaults # w:ru:User:Bot_of_the_Seven = https://ru.wikipedia.org/wiki/Участник:Bot_of_the_Seven $browser->agent('w:ru:User:Bot_of_the_Seven (LWP like Gecko) We come in peace'); # I need cookies exchange enabled for auth # here is doesn't matter but to give full LWP picture: $browser->cookie_jar( {} ); # a very few queries can be done by GET - most of MediaWiki require POST # so I do POST all around rather then remember where GET is allowed or not: my $response = $browser->request( POST 'https://ru.wikipedia.org/w/api.php', { 'format' => 'json', 'formatversion' => 2, 'errorformat' => 'bc', 'action' => 'query', 'list' => 'allusers', 'auactiveusers' => 1, 'aulimit' => 10, 'aufrom' => 'Б' } ); my $data = decode_json( $response->content ); my $test_scalar = $data->{query}->{allusers}[0]->{name}; my @test_array = @{ $data->{query}->{allusers} }[ 0 .. 2 ]; say "test array is @test_array"; say "-------"; dd \@test_array; say "-------"; print Dumper \@test_array; say "-------"; display_html( $test_array[1]->{name} ); sub display_html { use HTML::Entities; my $html_encoded = encode_entities(shift, '<>&"'); my @html = ( '', '', '', '', 'Мой тест', '', '', $html_encoded // 'Статус — ОК', # soft OR: 0 and empty string accepted '', '' ); # to avoid "wide character" warnings: binmode STDOUT, ':utf8'; print "Content-Type: text/html; charset=utf-8\n\n"; print join("\n", @html); } __END__ #### C:\Users\tblaz\Documents\evelyn>type 2.cyr.pl #!/usr/bin/perl -w use 5.011; ... sub display_html { use HTML::Entities; my $html_encoded = encode_entities(shift, '<>&"'); my @html = ( '', '', '', '', '╨£╨╛╨╣ ╤é╨╡╤ü╤é', '', '', $html_encoded // '╨í╤é╨░╤é╤â╤ü ΓÇö ╨₧╨Ü', # soft OR: 0 and empty string accepted '', '' ); # to avoid "wide character" warnings: binmode STDOUT, ':utf8'; print "Content-Type: text/html; charset=utf-8\n\n"; print join("\n", @html); } #### C:\Users\tblaz\Documents\evelyn>perl 1.hello.cyr.pl ╨ƒ╤Ç╨╕╨▓╨╡╤é #### #!/usr/bin/perl -w use 5.016; use utf8::all; #binmode STDOUT, ":utf8"; say "Привет"; __END__