Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/usr/bin/perl6
- use Inline::Perl5;
- use Mojo::DOM:from<Perl5>;
- my $p5 = Inline::Perl5.new;
- $p5.run(q'
- sub mojo_find {
- my ($m, $t) = @_;
- print $m;
- return $m->children($t);
- }
- ');
- for dir(test => /:i '.' html $/).sort -> $file {
- my $fh = $file.open;
- my $contents = $fh.slurp-rest;
- say "=== $file ===";
- #$contents ~~ s/.+? ('<' p.+? '>')/$0/;
- my $m = Mojo::DOM.new($contents);
- say $m;
- my $count = 0;
- #my @tags = $contents ~~ m:g/ :r '<' (<-[\s]>+(.+?)?) '>' (.+) '</' $0 '>'/;
- my @tags = $p5.call('mojo_find', $m, 'p');
- for @tags -> $t {
- say $t;
- last if $count++ > 10;
- }
- last;
- }
- ====
- Output
- ====
- $ perl6 reBase.pl
- === index_split_001.html ===
- Inline::Perl5::Perl5Object.new(ptr => NativeCall::Types::Pointer.new(216816896), perl5 => Inline::Perl5.new)
- Can't call method "tree" on an undefined value at /usr/local/share/perl/5.22.1/Mojo/DOM/HTML.pm line 166.
- in method call at /home/cbwood/.rakudobrew/moar-nom/install/share/perl6/site/sources/2DDC3CA4D43E8307229B622394E5256F089707DD (Inline::Perl5) line 472
- in block <unit> at reBase.pl line 30
- Attempt to free nonexistent shared string 'render', Perl interpreter: 0xb53fa58 during global destruction.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement