-
Notifications
You must be signed in to change notification settings - Fork 1
/
sendsig.pl
executable file
·46 lines (42 loc) · 1.03 KB
/
sendsig.pl
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
#!/usr/bin/perl
foreach $filename (@ARGV) {
open(COUNT,"grep -c \"^-- \$\" $filename |");
$max = <COUNT>;
chomp $max;
close(COUNT);
open(FILE,"<$filename") || die;
randomize;
$nr = $count = int rand($max);
# print "$max - $count\n";
#$nr = $count = 400;
while ($count > 0) {
$line = <FILE>;
if ($line =~ /^-- $/) {
$count--;
# print $line;
}
}
$output = "\n,---------------------------------<";
for ($empty = 3-length($nr); $empty > 0; $empty--) {
$output .= " ";
}
$output .= $nr . " of " . $max;
$output .=">-----------------------------------.\n";
while(true) {
$line = <FILE>;
if ($line =~ /^-- $/) {
last;
} else {
chomp $line;
$line = "|" . $line;
for ($empty = 81-length($line); $empty > 0; $empty--) {
$line .= " ";
}
$line .= "|\n";
$output .= $line;
}
}
$output .= "\`--------------------------------------------------------------------------------´\n";
print $output;
# $smtp = Net::SMTP->new('mailhost');
}