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.  
  30. while (!$quit) {
  31. show_logs();
  32.  
  33. print "\n(r: read, q: quit)\n";
  34. print ":";
  35. my $cmd = <STDIN>;
  36. chomp $cmd;
  37.  
  38. if ($cmd eq 'q') {
  39. $quit = 1;
  40. } elsif ($cmd eq 'r') {
  41. } else {
  42. post( "${api_url}write", { room => $room, name => $name, body => $cmd } );
  43. }
  44. }
  45.  
  46. post( "${api_url}leave", { room => $room, name => $name } );
  47. }
  48.  
  49. sub show_logs {
  50. my $res = post( "${api_url}read.tab", { room => $room, name => $name } );
  51. for (split /\n/, $res) {
  52. my ($time, $name, $color, $body) = split /\t/;
  53. print "$name\t$body ($time)\n";
  54. }
  55. }
  56.  
  57. sub post {
  58. my ($url, $args) = @_;
  59. return $ua->post( $url, $args )->content;
  60. }
  61.  
Runtime error #stdin #stdout #stderr 0s 3740KB
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.