Skip to content

Instantly share code, notes, and snippets.

@JJ
Created December 2, 2017 08:48
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 JJ/87509af610922b645a259e2b1c932eba to your computer and use it in GitHub Desktop.
Save JJ/87509af610922b645a259e2b1c932eba to your computer and use it in GitHub Desktop.
Finds the "good" in a series of sections
use Text::Markdown;
sub MAIN( Str $letter-to-santa = 'letters/dear-santa-sections.md' ) {
my $letter = Text::Markdown::Document.new($letter-to-santa.IO.slurp());
my $flip = False;
my @paragraphs = $letter.items.grep( { $flip = ($^þ ~~ Text::Markdown::Heading and $^þ.level == 2)?? !$flip !! $flip } );
say so any @paragraphs.map( {$^þ.Str ~~ /good/ } );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment