Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; use Term::ANSIColor; use Term::ReadLine; # also required: use IO::Handle; # Term::ReadLine::Gnu use IPC::Open2; $|=1; print "\e]2;T H C B;)\7"; print "User: "; my $User=<>; print "Pass: "; my $Pass=<>; open2(*TNIN, *TNOUT, "telnet desert-island.dynodns.net 4040"); TNOUT->autoflush(1); open(LOG, ">THCB.log"); LOG->autoflush(1); print TNOUT "auth ]$User [ $Pass"; my @c=("red","green","yellow","magenta"); my $n=0; my %hash; my $C=0; my $history=0; my @ray = ("blue on_yellow", "red on_green", "magenta on_blue", "black + on_magenta", "magenta on_cyan"); my $RLterm = new Term::ReadLine 'THCB input'; my $prompt="\nchat> "; alarm 120; my $m=2; my $dm=1; $RLterm->add_defun('F1-clip', sub{print TNOUT "<i>you talkin' to <b>me +</b></i> "}); $RLterm->bind_keyseq('\eOP','F1-clip'); $RLterm->add_defun('F2-clip', sub{print TNOUT "<i>reflects...</i>\n"}) +; $RLterm->bind_keyseq('\eOQ','F2-clip'); $RLterm->add_defun('F3-clip', sub{print TNOUT "<b>HELLO WORLD!</b>\n"} +); $RLterm->bind_keyseq('\eOR','F3-clip'); while (<TNIN>) { $SIG{ALRM}=sub{rearm()}; $SIG{INT}=sub{process()}; print LOG "$_"; chomp $_; if ($_ =~ /^Found you!\s?$/) {print "\e]0;$User\7" ;} my @line = split / /; my $chunk = shift @line; chomp @line; if ($chunk =~ /:$/) { if (exists($hash{$chunk})) {print color("$hash{$chunk} +"), "$chunk"} else {$hash{$chunk}="$ray[$C]"; $C++; print color("$hash{$chunk}"), "$chunk"; my $name; ($name = $chunk) =~ s/:/]/; $RLterm->add_history("[$name"); $history++; if ($C == 5) {$C=0} } print color("reset"); } else {print color("$c[$n]"), "$chunk "} print color("$c[$n]"), "@line "; print color("reset"); if ($n == 3) {$n=0} else {$n++} } sub process { my $input=$RLterm->readline($prompt); if ($input eq "DONE") {exit 0} elsif ($input =~/\*!\*$/) {return} else {print TNOUT "$input\n"} $RLterm->remove_history("$history"); } sub rearm { print color("white on_red"), "$m"; print "m"; print color("reset"); if ($dm == 4) {print LOG "***$m Minutes***\n";$dm=0;} alarm 120; $m += 2; $dm++; }

In reply to THCB by my_nihilist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found