3 #=======================================================================
5 # File ID: 421f1a82-483d-11e4-9469-c80aa9e67bbd
7 # Show IRC connections, output Graphviz data
10 # ©opyleft 2014– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = '0.00';
37 Getopt
::Long
::Configure
('bundling');
40 'count|c=i' => \
$Opt{'count'},
41 'debug' => \
$Opt{'debug'},
42 'help|h' => \
$Opt{'help'},
43 'verbose|v+' => \
$Opt{'verbose'},
44 'version' => \
$Opt{'version'},
46 ) || die("$progname: Option error. Use -h for help.\n");
48 $Opt{'debug'} && ($Debug = 1);
49 $Opt{'help'} && usage
(0);
50 if ($Opt{'version'}) {
54 $Opt{'count'} < 1 && die("$progname: -c/--count value has to be at least 1\n");
64 print("digraph g {\n");
65 while (my $curr = <>) {
66 # 20140829T003022Z < HisaoNakai> marmalodak: wat o_
67 if ($curr =~ /^\S+ <.(\S+?)> (\S+?):\s/) {
68 my ($from, $to) = ($1, $2);
69 $from =~ s/\\/\/g;
74 ($used{"$from $to"} == $Opt{'count'}) && print("\"$from\" -> \"$to\";\n");
84 # Print program version {{{
85 print("$progname v$VERSION\n");
91 # Send the help message to stdout {{{
94 if ($Opt{'verbose'}) {
100 Usage: $progname [options] [file [files [...]]]
102 Create Graphviz data from IRC logs.
107 Show only connections that have been repeated at least X times.
111 Increase level of verbosity. Can be repeated.
113 Print version information.
115 Print debugging messages.
118 irc-conn irc/2014/09/*.log | xdot
119 zcat irc/2014/09/*.log.gz | irc-conn -c 50 | dot -o conn.svg -Tsvg
120 zcat irc/2014/09/*.log.gz | irc-conn -c 50 | dot -Tx11
128 # Print a status message to stderr based on verbosity level {{{
129 my ($verbose_level, $Txt) = @_;
131 if ($Opt{'verbose'} >= $verbose_level) {
132 print(STDERR
"$progname: $Txt\n");
139 # Print a debugging message {{{
141 my @call_info = caller;
142 chomp(my $Txt = shift);
143 my $File = $call_info[1];
145 $File =~ s
#^.*/(.*?)$#$1#;
146 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
153 # Plain Old Documentation (POD) {{{
163 [options] [file [files [...]]]
173 =item B<-h>, B<--help>
175 Print a brief help summary.
177 =item B<-v>, B<--verbose>
179 Increase level of verbosity. Can be repeated.
183 Print version information.
187 Print debugging messages.
197 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
201 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
202 This is free software; see the file F<COPYING> for legalese stuff.
206 This program is free software: you can redistribute it and/or modify it
207 under the terms of the GNU General Public License as published by the
208 Free Software Foundation, either version 2 of the License, or (at your
209 option) any later version.
211 This program is distributed in the hope that it will be useful, but
212 WITHOUT ANY WARRANTY; without even the implied warranty of
213 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
214 See the GNU General Public License for more details.
216 You should have received a copy of the GNU General Public License along
218 If not, see L<http://www.gnu.org/licenses/>.
226 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :