Skip to content

Instantly share code, notes, and snippets.

@jberger
Created October 28, 2012 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/3969742 to your computer and use it in GitHub Desktop.
Save jberger/3969742 to your computer and use it in GitHub Desktop.
text_after a certain h4
#!/usr/bin/env perl
use strict;
use warnings;
use v5.10;
use Mojo::DOM;
my $dom = Mojo::DOM->new( <<'HTML' );
<div class="txt-block">
<h4 class="inline">Opening Weekend:</h4>
€2,137,456
(Italy)
(15 April 2012)
(420 Screens)
</div>
<div class="txt-block">
<h4 class="inline">Second Weekend:</h4>
€1,000,000
(Italy)
(22 April 2012)
(420 Screens)
</div>
HTML
say for $dom->find('div.txt-block h4.inline')
->grep(sub{$_->text eq 'Opening Weekend:'})
->pluck('text_after')
->each;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment