Absolutely, that's what tap is for. -Dan
On Fri, Aug 24, 2018 at 9:48 PM Stefan Adams <s1037...@gmail.com> wrote: > Sorry, I knew I should know better. > > I was using the ojo#x <https://mojolicious.org/perldoc/ojo#x> example and > I just added on to it: > > $ perl -Mojo -E 'say x(f("test.html")->slurp)->at("title")->content("NEW > TEXT")' > > I've lost access to the dom! I needed to store the dom object in a > variable so I could get back to the dom after looping thru find: > > $ perl -Mojo -E 'my $dom = x(f("test.html")->slurp); > $dom->at("title")->content("NEW TEXT"); say $dom' > > There was a discussion recently about tap. Is this a good use for tap? > > $ perl -Mojo -E 'say > x(f("index.html")->slurp)->tap(sub{$_->at("title")->content("NEW TEXT")})' > > Now I have the full dom with my updated information! > > On Fri, Aug 24, 2018 at 8:24 PM Stefan Adams <s1037...@gmail.com> wrote: > >> Can Mojo::DOM be used to update information in a tree? For example, if I >> want to strip the host from all links, I might ->find('a[href]') and then >> loop through the collection to do some updates. But unless I'm missing >> something, I can't then update the original dom with these changes. >> > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To post to this group, send email to mojolicious@googlegroups.com. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.