#!/usr/bin/perl -w # garp [-0i] [MATCH]... [!NOTMATCH]... - grep with multiple expressions # -0 split at nul, -00 split at paragraph, -000 look at whole file # -i case insensitive use Getopt::Long qw(:config no_ignore_case require_order bundling); use Data::Dumper; my $r = 1; my $ic = ""; my @sep = ("\0", "", undef); GetOptions ('i' => sub {$ic = "(?i)"}, '0' => sub {$/ = shift @sep}) || exit 2; for $rx (@ARGV) { "" =~ $rx } # check regex syntax LINE: while () { for $rx (@ARGV) { if ($rx =~ /^!/) { m/$ic$'/ && next LINE; } else { m/$ic$rx/ || next LINE; } } print; $r = 0; } exit $r;