Skip to content

Commit 665df65

Browse files
authored
feat: rcg.pl
1 parent e943fc2 commit 665df65

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

rcg.pl

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/perl -w
2+
#
3+
# regexp coloured glasses - from Linux Server Hacks from O'Reilly
4+
#
5+
# eg ./rcg "fatal" "BOLD . YELLOW . ON_WHITE" /var/adm/messages
6+
#
7+
use strict;
8+
use Term::ANSIColor qw(:constants);
9+
10+
my %target = ( );
11+
12+
while (my $arg = shift) {
13+
my $clr = shift;
14+
15+
if (($arg =~ /^-/) | !$clr) {
16+
print "Usage: rcg [regex] [color] [regex] [color] ...\n";
17+
exit(2);
18+
}
19+
20+
#
21+
# Ugly, lazy, pathetic hack here. [Unquote]
22+
#
23+
$target{$arg} = eval($clr);
24+
25+
}
26+
27+
my $rst = RESET;
28+
29+
while(<>) {
30+
foreach my $x (keys(%target)) {
31+
s/($x)/$target{$x}$1$rst/g;
32+
}
33+
print
34+
}

0 commit comments

Comments
 (0)