-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbadmouth
More file actions
executable file
·63 lines (54 loc) · 1.32 KB
/
badmouth
File metadata and controls
executable file
·63 lines (54 loc) · 1.32 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl
use strict;
use v5.12;
use Cwd qw(abs_path);
use Regexp::Common qw(profanity);
use File::LsColor ();
use Data::Dumper;
{
package Data::Dumper;
no strict 'vars';
$Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1;
$Quotekeys = 0;
}
use feature qw(switch);
$0 = basename($0);
{
warn "hm.\n";
eval {
use autodie;
open(my $fh, '|-', 'ls_color_internal');
print "hello.pl";
close($fh);
open(my $fh, '-|', 'ls_color_internal');
};
given ($@) {
when (undef) { select STDOUT; say "No error"; }
when ('open') { say "Error from open()\n $@"; }
when (':io') { say "Non-open, IO error."; }
when (':all') { say "All other autodie errors." }
default { select STDOUT; say " it is better to die() than to return() in failure" }
}
select STDOUT;
}
*ls = *File::LsColor::ls_color_internal;
my $stats = { };
@ARGV = '-' unless @ARGV;
if($ARGV[0] eq '-') {
while(<>) {
m/($RE{profanity})/ and print "$.: $1\n";
}
}
else {
for my $f(@ARGV) {
open my $fh, '<', $f or next;
for my $line(<$fh>) {
if($line =~ m,($RE{profanity}),i) {
push( @{ $stats->{$1} }, $f);
printf "%s:%-5d %s\n",
ls(sprintf("%20s", $f)), $., $1;
}
}
}
}
print Dumper $stats;