forked from beyondgrep/ack1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
squash
executable file
·40 lines (30 loc) · 931 Bytes
/
squash
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
29
30
31
32
33
34
35
36
37
38
39
40
#!perl
# Quickie utility for squashing together the parts for the standalone version
use warnings;
use strict;
use File::Next;
for my $arg ( @ARGV ) {
my $filename = $arg;
if ( $arg =~ /::/ ) {
my $key = "$arg.pm";
$key =~ s{::}{/}g;
$filename = $INC{$key} or die "Can't find the file for $arg";
}
warn "Reading $filename\n";
open( my $fh, '<', $filename ) or die "Can't open $filename: $!";
while ( <$fh> ) {
next if /^use (File::Next|App::Ack)/;
# See if we're in module POD blocks
my $skip = ($filename ne 'ack') && (/^=/ .. /^=cut/);
if ( !$skip ) {
# Replace the shebang line
s{^#!.+}{#!/usr/bin/env perl};
# Remove Perl::Critic comments.
# I'd like to remove all comments, but this is a start
s{\s*##.+critic.*}{};
print;
}
}
close $fh;
}
exit 0;