Say Perl

Worldwide Perl Blogging

Totally
311 feeds,
9627 posts.

How can I get a latest release information from metacpan API?

25 July, 09:33, by tokuhirom, machine translated from Afrikaans

for id: punitan

#! / Usr / bin / perl
use strict;
use warnings;
use utf8;
use 5.010000;

use JSON;
use LWP:: UserAgent;

my $ ua = LWP:: UserAgent-> new ();

my $ rest = $ ua-> post (
    "Http://api.metacpan.org/v0/release/_search '
    Content => encode_json (
        {   
            size => 20,
            from => 0,
            sort => [{'date' => {order => "desc"}}]
            query => {match_all => {}}
            fields => [
                QW (author version DOWNLOAD_URL distribution date)
            ]
        }
    )
);
$ Rest-> is_success or die "Fail to get the latest information modules". $ Rest-> status_line;
my $ that = JSON:: decode_json ($ rest-> decoded_content);
for my $ row (map {$_->{ areas}} @ {$ that-> {hits} -> {hits}}) {
    say "$ row-> {distribution} $ row-> {version} to $ row-> {author} - $ row-> {DOWNLOAD_URL}";
}

Youtube downloader

30 December, 21:07, machine translated from Afrikaans

Понадобилось, вдруг, скачать несколько роликов с ютуба, оказалось нечем. Мой старый не работает, Злобинский тоже не работает, youtube-dl из убунтовского репозитория тоже не работает. Пришлось делать новый.

#! / Usr / bin / perl -
# 
 # Ytd.pl - youtube downloader

use strict;
use warnings;
use lwp:: useragent;
use URI:: Escape;

the "Usage: ytd.pl VideoURL \ n" Unless @ ARGV;

my $ videourl = shift;
my $ ua = lwp:: UserAgent-> new;
my $ response = $ ua-> get ($ videourl);
my ($ outflv) = $ response-> content = ~ m {<meta name="description" content=" ([^ "] +) ">};

the "Can not find video title \ n" Unless $ outflv;

while (-e "$ outflv.flv) {
  $ Outflv outflv = $ = ~ / _ (\ d +) $ /? "${`}_". ($ 1 +1): $ {} _1 outflv;
}

my $ link = [map {map {split '\ |'} split '', uri_unescape ($ _)} $ response-> content = ~ m {fmt_url_map = ([^ &] +)}] -> [1 ];
the "Can not find video link \ n" Unless $ link;

$ | = 1;

print "Saving to $ outflv.flv video ... \ n";

my ($ received_size, $ i) = (0, 0);
open my $ fh, '>', "$ outflv.flv" or

Untitled

11 September, 13:37, machine translated from Afrikaans

Добрый день, господа!

Подскажите, почему такой скрипт:

#! / Usr / bin / perl

use strict;
use IO:: Socket:: UNIX;

sockaddr_un (test.sock)
or die "Can not create server: $!";

my $ Sock = IO:: Socket:: UNIX-> new (Peer => "test.sock '
Type => 'sock_stream');
The "$!" unless $ Sock;

Выдаёт ошибку: "Protocol not supported"?

Perl. Получение ссылок на mp3 из подкаста

2 September, 08:40, machine translated from Afrikaans

 #! / Usr / bin / env perl 
use common: sense; use ojo; the "Usage: $ 0 <podcast url>" unless @ ARGV; b (g (shift) -> dom-> find ('enclosure [url]) -> each (sub ( local $ _ = shift -> attrs-> (url); say if / \. mp3 $ /; )));

http://gist.github.com/562053

Привет, хейтерам Perl:)


or the use Mojolicious;

use Perl or die;

JFDI


ЗЫ: пизжи только на похапе или или CAS AJAX:)