So I decided to write an IRC client because all those others either don't support SOCKS or are too big. I was under the impression it would be a 10-minute project because the lovely POE::Component::IRC did all the work for me, but I've run across a problem. It fails to actually connect to anything, it just sits there. What's the problem? Code follows.
#!/usr/bin/perl use strict; use warnings; use POE::Component::IRC; use Tk; use YAML qw( LoadFile ); my $mw = MainWindow->new(); my $chan = $mw->Entry( -width => 10 )->pack(); my $join = $mw->Button( -text => 'Join', -command => sub { join($chan) + } )->pack(); my $in = $mw->Entry( -width => 80 )->pack(); $mw->Button( -text => 'Send', -command => sub { enter($in,$chan) } )-> +pack(); my $out = $mw->Text()->pack(); my @arg = %{ LoadFile("config_ircclient.yml") }; my $irc = POE::Component::IRC->spawn( @arg ) || die( "Huh?!\n" ); POE::Session->create( package_states => [ 'main' => [ qw( _default _start irc_001 irc_public irc_msg ) ] ], heap => { irc => $irc } ); if ( fork() ) { MainLoop; } else { POE::Kernel->run(); } sub _start { my $session = $irc->session_id(); POE::Kernel->post( $session => register => 'all' ); POE::Kernel->post( $session => connect => {} ); sendmsg( "POE is starting.\n" ); undef; } sub irc_001 { sendmsg( "Connected.\n" ); undef; } sub irc_public { my ($kernel,$sender,$who,$where,$what) = @_; my $nick = ( split /!/, $who )[0]; my $channel = $where->[0]; sendmsg( "$channel: $nick: $what\n" ); undef; } sub _default { my ( $event, $args ) = @_; my @output = ( "$event: " ); foreach my $arg ( @$args ) { if ( ref($arg) eq 'ARRAY' ) { push( @output, "[" . join(" ,", @$arg ) . "]" ); } else { push ( @output, "'$arg'" ); } } sendmsg( join( " ", @output ) . "\n" ); undef; } sub irc_msg { my ( $sender, $msg ) = ( (split(/!/,$_[0]))[0], $_[2] ); sendmsg( "PRIVMSG: $sender: $msg\n" ); undef; } sub enter { $irc->yield( privmsg => $_[1]->get() => $_[0]->get() ); $_[0]->selectionClear(); } sub sendmsg { $out->insert( 'end', $_[0] ); print "$_[0]"; } sub join { $irc->yield( join => $_[0] ); }

In reply to Perl/Tk IRC client by Anonymous Monk

Title:
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, details, 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, summary, 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.