#! /usr/bin/env perl $key = "c"; $select = 1; # Read switches. while ( $_ = $ARGV[0], /^-/ ) { shift; last if /^--$/; if ( /^-f/ ) { $key = "f" }; } # Read input lines. line: while (<>) { # Detect start of prologue and initialise prologue text. if ( /^[fc]\+ *$/ ) { $select = 0; if ( /^$key\+ *$/o ) { $select = 1; } next line; } # Detect end of prologue. if ( /^[fc]- *$/ ) { $select = 1; next line } # Process the prologue contents. if ( $select ) { print; } }