chella2104@gmail.com has asked for the wisdom of the Perl Monks concerning the following question:

use strict; use warnings; use Mojo; use feature 'say'; my $ua = Mojo::UserAgent->new; my $array=$ua->get('http://blogs.perl.org/')->res->dom->find('div > p + ')->map('text')->join("\n"); my @arr=split("\n",$array); print "\n".$arr[0]."\n";

Output is

lets you write your Perl 6 code using Roman numerals:

but I want output is

perl6-slang-roman lets you write your Perl 6 code using Roman numerals:

anyone can help me

Replies are listed 'Best First'.
Re: how to print div tag value with a href tag in perl
by Corion (Patriarch) on Jan 11, 2016 at 11:55 UTC

    What is the relevant part of the HTML you're parsing? Also, are you certain that this is a Perl problem at all? I think the problem is mostly related to CSS selectors.

    Maybe you want to solve the problem in two steps:

    1. Extract the text that goes before the text you have
    2. Extract the text you have already

    The desired output is then constructed by printing the first text and then printing the second text.

    Update: After thinking a bit more about your problem, you most likely seem to want to extract just the text of a node and all its children. I would read the Mojo::DOM documentation as I don't know the Mojo API. But most likely, it consists of 1. getting all the children of a node, and 2. getting the text of each child.

Re: how to print div tag value with a href tag in perl
by poj (Abbot) on Jan 11, 2016 at 15:00 UTC

    Try ->map('all_text') instead of ->map('text')

    poj
Re: how to print div tag value with a href tag in perl
by Anonymous Monk on Jan 11, 2016 at 23:12 UTC
A reply falls below the community's threshold of quality. You may see it by logging in.