blob: 45c64134f88c265857d8ee1f132783c16cff5207 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/usr/bin/perl
my $pat = shift(@ARGV) || usage(1);
my $infile = shift(@ARGV) || usage(1);
my $outfile = shift(@ARGV) || "-";
print STDERR "Package-strip processing input file $infile\n";
print STDERR "Output to " . ($outfile ne "-" ? $outfile : "stdout") . "\n";
# massage the regexp to accept semi-shell-style *
$pat =~ s/\*/.*/g;
open (I,"<$infile") || die $@;
open (O,">>$outfile") || die $@;
undef $/;
my $srctext = <I>;
close(I);
my @srclist = split(/\012\012\012/,$srctext);
my @outlist = grep(/Package: $pat/,@srclist);
print O join("\012\012\012",@outlist);
print O "\012\012\012";
sub usage {
my $cack = shift(@_);
print STDERR "usage: Package-strip <regexp> <filename> [output filename]\nRemember to escape wildcard characters for the shell.";
die if $cack;
}
|