use strict; use warnings; use LWP::UserAgent; use XML::Twig; binmode(STDOUT, "encoding(UTF-8)"); my $xml = LWP::UserAgent->new->get('https://www.youtube.com/feeds/videos.xml?playlist_id=PLA9_Hq3zhoFyOpb-U3DMU7OT93dPUdtpE')->decoded_content; my ($title_title, $title_name, @elements); my $twig= XML::Twig->new( twig_handlers=>{ '/feed/title' =>sub{ $title_title = $_[1]->text }, '/feed/author/name' =>sub{ $title_name = $_[1]->text }, '/feed/entry' =>sub{ my @found; push @found, $_[1]->first_child('title')->text, ( split ':',$_[1]->first_child('id')->text)[2]; # damn schema prefix i cant get rid of it without this ugly... for ($_[1]->descendants ){push @found, $_->text if $_->gi eq 'media:description'} push @elements,\@found; }, } ); $twig->parse($xml); print <<"EOT";
$ele->[2]