<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi!<br><br></div>Nachdem ich mich jetzt mit Inline::Perl5 rumspiele, bin ich auch schon auf das erste Problem gestoßen:<br><br>use v6;                                                                                                           <br>                                                                                                                   <br>use LWP::Simple;                                                                                                  <br><br>use Mojo::DOM:from<Perl5>;                                                                                        <br>use YAML::XS:from<Perl5>;                                                                                         <br><br>my $html = LWP::Simple.get('<a href="https://metacpan.org/pod/Mojo::DOM'">https://metacpan.org/pod/Mojo::DOM'</a>);<br><br>my $dom = Mojo::DOM.new($html);                                                                                   <br><br></div><div># funzt<br></div><div>say $dom.find('body > div.container-fluid > div:nth-child(2) > div > div > div.pod.content.anchors > p:nth-child(3)').first.text;<br><br></div><div>#geht nicht<br></div><div>say $dom.find('body > div.container-fluid > div:nth-child(2) > 
div > div > div.pod.content.anchors > 
p:nth-child(3)').[0].text;<br><br></div>Mein Problem ist das $dom.find. Das gibt ein Mojo::Colection Objekt zurück. In perl5 greife ich dann mit $dom.find('CSS Selector')->[0] auf das erste gefundene Element zu, dass dann wieder ein Mojo::DOM Objekt ist. Folgendes ist also erlaubt:<br></div>$dom.find('irgendwas')->[0].find('was anderes')->[0]...<br></div>Mit Inline::Perl5 funktioniert das nicht:<br></div>$dom.find('irgendwas').[0].find(...) gibt den Fehler:<br></div>Mojo::Collection does not have a find method.<br><br></div>Mit .first funktionierts, aber was wenn ich das zweite Element haben will?<br></div>Ist die .[0] Syntax falsch?<br><br></div>THX,<br></div>Wolf<br></div>