tagged release 0.6.4
[parrot.git] / tools / dev / nopaste.pl
blob708f9aaaced987fd7a0dac795909975f2e2a92a5
1 #!perl
3 # Copyright (C) 2008, The Perl Foundation.
4 # $Id$
6 use 5.008;
7 use strict;
8 use warnings;
10 use WWW::Mechanize;
11 use Getopt::Std;
14 my $server = 'nopaste.snit.ch';
15 my $url = "http://$server:8001/paste";
16 my $opt = {
17 c => undef, # channel
18 n => getlogin || getpwuid($<) || 'someone', # name
19 t => undef, # title
22 getopt( 'c:n:t:', $opt );
24 usage()
25 unless defined $opt->{t};
28 my $text; while(<>) { $text .= $_; }
29 my $mech = WWW::Mechanize->new(
30 cookie_jar => undef,
31 autocheck => 1,
34 $mech->get( $url );
36 $mech->submit_form(
37 form_name => 'pasteForm',
38 fields => {
39 (defined $opt->{c} ?
40 (channel => $opt->{c}) :
43 nick => $opt->{n},
44 summary => $opt->{t},
45 paste => $text,
47 button => 'Paste it',
50 my @link = $mech->links;
51 print "Your paste can be found at ", $link[0]->url, "\n";
54 sub usage {
55 print <<USAGE;
56 nopaste.pl - paste the contents of a file via $server
58 nopaste.pl -t "TITLE" [ -c CHANNEL ] [ -n NAME ] [ FILENAME ]
60 TITLE the title of the paste
61 CHANNEL the irc channel (defaults to undef)
62 NAME the username (defaults to username or 'someone')
63 FILENAME the name of the file to paste (defaults to STDIN)
64 USAGE
65 exit 0;
68 # Local Variables:
69 # mode: cperl
70 # cperl-indent-level: 4
71 # fill-column: 100
72 # End:
73 # vim: expandtab shiftwidth=4: