Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl # - Talking Perl Monks # By Joe Stewart # Mainly just a hack to the sample driver program for # by Diego Zamboni, May 2000. # # Use: # -l Username # Asks for your password. Stores cookies in ~/.pm-cookie. # This is only necessary the first time you use it. After that it + uses # the cookie automatically. # Type messages to send # Type /checkoff <number> to remove personal messages (this is the equ +ivalent # of checking on them in the web page). # use strict; use PerlMonksChat; use IO::Select; use Text::Wrap qw(wrap); use Speech::Festival; $| = 1; $SIG{'INT'} = \&endit; my $festival = new Speech::Festival; conn $festival || warn "Could not connect to festival: $!"; my $user; my $passwd; my $usecolor=1; my $color_username=""; my $color_personalmsg=""; my $color_sysmsg=""; my $color_normal=""; if ($ARGV[0] && $ARGV[0] eq "-l") { shift @ARGV; $user=shift @ARGV or die "User expected as argument to -l\n"; print "Password? "; $passwd=<STDIN>; chomp $passwd; } my $period=shift @ARGV || 10; if ($usecolor) { eval "use Term::ANSIColor"; unless ($@) { $color_username=color('BOLD GREEN'); $color_personalmsg=color('YELLOW BOLD'); $color_sysmsg=color('RED'); $color_normal=color('reset'); } } my $p=PerlMonksChat->new(); $p->add_cookies; if ($user) { $p->login($user, $passwd); } my $s=IO::Select->new; $s->add(\*STDIN); while (1) { my @lines = map { s/^(<[^>]+>)/$color_username$1$color_normal/; s/^(\(\d+\)\s*\*.*)$/$color_personalmsg$1$color_normal +/; wrap("", "\t", "$_\n") } $p->getnewlines(1); for (@lines) { print; &speak_to_me($_); } my @ready=$s->can_read($period); if (@ready) { foreach (@ready) { my $line=<$_>; chomp $line; if ($line =~ /^\/?(checkoff|co)\s+/ && (my @ids=($line=~/(\d+) +/g))) { $p->checkoff(map { 'deletemsg_'.$_ } @ids); print $color_sysmsg, "* Done *", $color_normal,"\n"; } elsif ($line =~ /^\s*\/quit\s*$/) { exit; } else { $p->send($line); } } } } sub speak_to_me($) { my $text = shift; $text =~ s/^.*?\s+//; request $festival "(SayText \"$text\")"; } sub endit { print "Disconnecting from Festival: "; disconnect $festival; exit; }

In reply to Monktalk by httptech

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (5)
    As of 2018-06-20 13:54 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.