106 ^L[18:27:43 kelly@kudzu lab6]$ cat 4.pl 107 #! /usr/bin/perl 108 # 109 # CIS 33A Programming In Perl 110 # Lab #6.4 111 # Due Date: Monday, Nov 22 112 # Written By: Kelly Price 113 # 114 use strict; 115 use warnings; 116 117 die "Usage: $0 infile outfile regexs...\n" if @ARGV < 3; 118 open(FIN, "$ARGV[0]") or die "Error openning $ARGV[0] for reading: $!\n"; 119 open(FOUT, ">$ARGV[1]") or die "Error openning $ARGV[1] for writing: $!\n"; 120 121 my (@regexs) = splice(@ARGV, 2); 122 my $rexs = '(' . join('|', @regexs) . ')'; 123 124 my $inblock = 0; 125 print FOUT grep { 126 my $match = 0; 127 if (/$rexs/) 128 { 129 $inblock = $inblock ? 0 : 1; 130 $match = 1; 131 } 132 $inblock or $match; 133 } ; 134 135 [18:27:46 kelly@kudzu lab6]$ 4.pl 4.pl 4.out \\{ \\} 136 [18:28:00 kelly@kudzu lab6]$ cat 4.out 137 print FOUT grep { 138 my $match = 0; 139 if (/$rexs/) 140 { 141 } 142 $inblock or $match; 143 } ;