File: publish.pl

package info (click to toggle)
libredis-fast-perl 0.34%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 492 kB
  • sloc: perl: 2,630; makefile: 7
file content (18 lines) | stat: -rwxr-xr-x 324 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
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> ";
}