File: loopback.pl

package info (click to toggle)
libscriptalicious-perl 1.15-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 180 kB
  • ctags: 70
  • sloc: perl: 1,150; makefile: 16
file content (32 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (6)
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

use Scriptalicious;

my $ifd = fileno(STDIN);
my $ofd = fileno(STDOUT);

getopt("ifd|i=i" => sub {
	   close STDIN;
	   open STDIN, "<&$_[1]" or do {
	       moan "failed to open input fd $_[1]; $!";
	       sleep 60;
	   };
       },
       "ofd|o=i" => sub {
	   close STDOUT;
	   open STDOUT, ">&$_[1]" or do {
	       moan "failed to open output fd $_[1]; $!";
	       sleep 60;
	   };
       },
      );

my $lines = 0;
while ( <STDIN> ) {
    $lines++;
    chomp;
    say "got `$_'";
}

say "saw $lines line(s) on input";

close STDIN;