blob: f9750b6b1d393e1ff8914ee7b3b185647627c74c (
plain) (
blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
use Getopt::Long;
my $nick = $ENV{USER};
my $lang = "C";
my $desc = "";
my $tabs = "No";
my $text = "";
my $host = "rafb.net/paste";
sub usage {
print <<"END_USAGE";
Usage: $0 <options>
Reads paste from STDIN
Options:
--nick=NICK Paste as NICK (default \$USER)
--language= Set the language for syntax highlighting
--description= Set the paste description
--tabs= Set how many spaces a tab should be
--host= Use a different host other than $host
END_USAGE
exit(-1);
}
GetOptions("nick=s" => \$nick,
"language=s" => \$lang,
"description=s" => \$desc,
"tabs=s" => \$tabs,
"host=s" => \$host)
or usage();
$text = do { local $/; <> };
my $mech = WWW::Mechanize->new();
$mech->get("http://$host");
$mech->submit_form(
form_number => 1,
fields => {
nick => $nick,
lang => $lang,
desc => $desc,
cvt_tabs => $tabs,
text => $text,
}
);
print "Pasted to: " . $mech->uri(), "\n";
|