/ bin / ix
ix
 1  #!/usr/bin/perl
 2  
 3  use strict;
 4  use warnings;
 5  
 6  use HTTP::Tiny;
 7  if ($^O eq "openbsd") {
 8  	require OpenBSD::Pledge;
 9  	require OpenBSD::Unveil;
10  
11  	OpenBSD::Unveil::unveil("/", "") or die;
12  	OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
13  }
14  
15  my $http = HTTP::Tiny->new();
16  
17  sub slurp {
18  	my ($fh) = @_;
19  	local $/;
20  	<$fh>;
21  }
22  
23  sub sprunge {
24  	my ($input) = @_;
25  	my $url = "http://ix.io";
26  	my @form = ( 'f:1=<-' => $input );
27  	my $resp = $http->post_form($url, \@form)
28  		or die "could not POST: $!";
29  	$resp->{content};
30  }
31  
32  my $input = slurp('STDIN');
33  my $url = sprunge($input);
34  print $url;
35