File: publish.pl

package info (click to toggle)
libredis-perl 2%3A2.000-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 416 kB
  • sloc: perl: 2,695; makefile: 4
file content (27 lines) | stat: -rwxr-xr-x 520 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
#
# This file is part of Redis
#
# This software is Copyright (c) 2015 by Pedro Melo, Damien Krotkine.
#
# This is free software, licensed under:
#
#   The Artistic License 2.0 (GPL Compatible)
#
use warnings;
use strict;

use Redis;

my $pub = Redis->new();

my $channel = $ARGV[0] || die "usage: $0 channel\n";

print "#$channel > ";
while (<STDIN>) {
  chomp;
  $channel = $1 if s/\s*\#(\w+)\s*//;    # remove channel from message
  my $nr = $pub->publish($channel, $_);
  print "#$channel $nr> ";
}