#!/usr/bin/perl # ##################################################### # angelgrep -- for Stephen D'Angelo's MtG rulings # copyright Tom Christiansen -- All Rights Reserved # tchrist@mox.perl.com # Tue Jun 20 08:14:20 MDT 1995 ##################################################### require 5.0; # for superduper regexps use English; # for legibility :-) use Getopt::Std; # easier than rolling your own $RS = ''; # paragrep mode $AUTOFLUSH = 1; # for hungry pagers getopts('shine') or usage(); $query = shift or usage("Need query"); unless (eval{/$query/,1}) { $EVAL_ERROR =~ s/in regexp at.*//; die "$PROGRAM_NAME: pattern wouldn't compile: $EVAL_ERROR"; } $query = '(?i)' . $query if $opt_i; # here's where I keep my version of these files.... @ARGV = if !@ARGV and -t; while (<>) { # YANETUT s/^(([A-Z].*?)(:.*?)*?)(:\s*)?\n// and ($3 || $4 ? $card : $sect) = $1; next if /^\s*[=-]/; for (split /\n(?= \S|\+)/) { s/\s+/ /g; s/^ //; $new = s/^\+\s+// ? '+' : ''; next if $opt_n and !$new; s/([a-z]\.) ([A-Z])/$1\n$2/g if $opt_s; if ( ($opt_e ? $card : $_) =~ /$query/o || (!$opt_e && $opt_h && $card =~ /$query/o)) { s/\n/ /g if $opt_s; write; ($psect, $pcard) = ($sect, $card); } } } ########################################################### sub usage { warn "@ARG\n" if @ARG; die <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ($psect ne $sect or $pcard ne $card) ? ($card, $sect) : () @ ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $new, $_ ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $_ . # if there isn't a dot by itself on the previous line, an EEEEVIL mail # or news transport agent ate it, and you will lose big. ########################################################### __END__