我有这样的HTML
<h1>My heading</h1>
<p class="class1">
<strong>SOMETHING</strong> INTERESTING (maybe not).
</p>
<div class="mydiv">
<p class="class2">
<a href="http://www.link.com">interesting link</a> </p>
<h2>Some other heading</h2>
Run Code Online (Sandbox Code Playgroud)
h1和h2之间的内容各不相同 - 我知道我可以在Mojo :: Dom中使用css选择器,比如选择h1或h2或p标签的内容 - 但是如何选择h1和h2之间的所有内容?或者更一般地说,任何两个给定标签集之间的所有内容?
我试图使用数据库查询将查询输出打印到CSV但无法将输出打印到单独的行.怎么办?
这是代码:
use warnings;
use DBI;
use strict;
use Text::CSV;
#set up file
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, ">:encoding(utf8)", "new.csv" or die "new.csv: $!";
#set up query
my $dbh = DBI->connect("DBI:mysql:db", "name") or die ("Error: $DBI::errstr");
my $sql = qq(select * from one_table join two_table using (primary_key));
my $query = $dbh->prepare($sql);
$query->execute;
#loop through returned rows of query and …Run Code Online (Sandbox Code Playgroud)