Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: splitting results

by davido (Cardinal)
on Dec 17, 2020 at 22:12 UTC ( #11125373=note: print w/replies, xml ) Need Help??


in reply to splitting results

I'm doing it in Mojo::DOM:

#!/usr/bin/env perl use strict; use warnings; use Mojo::DOM; use Mojo::Util qw(trim); my $content = <<'HERE'; <td class="">info</td> <td> john </td> <td> 100 - 200 </td> <td> kent </td> HERE my $dom = Mojo::DOM->new($content); my ($data, $left_name, $range, $right_name) = map {trim($_->content)} +@{$dom->find('td')}; my ($left_val, $right_val) = split /\s*-\s*/, $range; print "data:$data $left_name:$left_val $right_name:$right_val\n";

That produces:

data:info john:100 kent:200


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11125373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2021-03-01 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (13 votes). Check out past polls.

    Notices?