Bored waiting for installs to finish. Thanks for an entertaining question:

#!/usr/bin/perl -wl # gate : a printer gate use strict; use Getopt::Std; use constant OPEN => 1; use constant SHUT => 0; use vars qw($opt_p $opt_o $opt_s $opt_b $opt_l); local ($opt_p, $opt_o, $opt_s, $opt_b, $opt_l); getopts(qw(pb:o:s:l:)); unless ($opt_o or $opt_b ){ usage() unless $opt_p; } if (@ARGV){ open FH, $ARGV[0] or die $!; } else { *FH = \*DATA ; } my $enter = $opt_p ? $opt_p : SHUT; # breeze my $breach = $opt_b ? $opt_b : 'the burgler breaks in'; my $open = $opt_o ? $opt_o : 'the butler opens the door'; my $shut = $opt_s ? $opt_s : 'the bouncer shuts the door'; my $last = $opt_l ? $opt_l : 'the bellhop is last through the door +'; while (my $door = $_ = <FH>){ chomp ($door,$_); exit if $door =~ /^$shut$/; # bouncer $enter = OPEN if $door =~ /^$breach$/; # burgler $enter and print; $enter = OPEN if $door =~ /^$open$/; # butler exit if $door =~ /^$last$/; # bellhop } sub usage { print "The door is shut\n", "$0 -p (p_neuma is Greek for 'breeze') -b (burgler b_reaks in) <item> -o (butler o_pens the door) <item> -s (bouncer s_huts the door) <item> -l (bellhop is l_ast through the door)<item> "; die"\n"; } __END__ apple banana pear peach grape orange

$ gate -o banana -s grape
pear
peach
update2
$ gate -o apex -s apple ./words
apexed
...
applausively
mkmcconn


In reply to Re: Finding part of a file by mkmcconn
in thread Finding part of a file by willa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.