#!/usr/bin/perl # eg: for each command given as argument, # search for "EXAMPLES" and print everything from there to the # beginning of the next section heading. # Copyright 2002 by Akkana Peck. # You may use or modify this program under the terms of the GPL. # Usage: eg cmd1 cmd2 ... @fils = @ARGV; for ($i = 0; $i <= $#fils; ++$i) { $printing = 0; open(MANPROC, "man $fils[$i] |") or die "Can't run program: man $fils[$i]\n"; while () { if ($printing != 1 && $_ =~ /E.*X.*A.*M.*P.*L.*E/) { $printing = 1; print "-------------------------------------------------\n"; print "- $fils[$i]\n"; print "-------------------------------------------------\n"; } elsif ($printing == 1 && $_ =~ /^[A-Z]/) { $printing = 0; } if ($printing == 1) { print "$_"; } } }