fork download
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use LWP;
  6.  
  7. my $api_url = 'http://c...content-available-to-author-only...l.cx/api/';
  8.  
  9. my $name = shift @ARGV or usage();
  10. my $room = shift @ARGV || 'lounge';
  11.  
  12. my $ua = LWP::UserAgent->new;
  13.  
  14. main();
  15.  
  16. sub usage {
  17. print "\n", <<END; exit;
  18. Usage: perl $0 name [room]
  19.  
  20.   name your handle name.
  21.   room chat room to enter. if omitted, 'lounge' is used.
  22. END
  23. }
  24.  
  25. sub main {
  26. my $quit = 0;
  27.  
  28. post( "${api_url}enter", { room => $room, name => $name } );
  29. show_logs();
  30.  
  31. while (!$quit) {
  32. print "\n(r: read, q: quit)\n";
  33. print ":";
  34. my $cmd = <STDIN>;
  35. chomp $cmd;
  36.  
  37. if ($cmd eq 'q') {
  38. $quit = 1;
  39. last;
  40. } elsif ($cmd eq 'r') {
  41. show_logs();
  42. } else {
  43. post( "${api_url}write", { room => $room, name => $name, body => $cmd } );
  44. show_logs();
  45. }
  46. }
  47.  
  48. post( "${api_url}leave", { room => $room, name => $name } );
  49. }
  50.  
  51. sub show_logs {
  52. my $res = post( "${api_url}read.tab", { room => $room, name => $name } );
  53. for (split /\n/, $res) {
  54. my ($time, $name, $color, $body) = split /\t/;
  55. print "$name\t$body ($time)\n";
  56. }
  57. }
  58.  
  59. sub post {
  60. my ($url, $args) = @_;
  61. return $ua->post( $url, $args )->content;
  62. }
  63.  
Runtime error #stdin #stdout #stderr 0s 3696KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Can't locate LWP.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.16.2/i686-linux /usr/lib/perl5/site_perl/5.16.2 /usr/lib/perl5/5.16.2/i686-linux /usr/lib/perl5/5.16.2 .) at prog.pl line 5.
BEGIN failed--compilation aborted at prog.pl line 5.