sorry to bust your bubble kid, but the first loop is all that will be engaged since its infinite. also, why not the newlines off...
#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket::INET;
my ($host,$port,$nick,$ident,$real,$chan) = @ARGV;
die("usage: $0 <irc.server.net> <6667> <nick> <ident> <realname> <#channel>") unless $chan;
my $socket = IO::Socket::INET->new( PeerAddr => $chan,
PeerPort => $port,
Proto => 'tcp',
Timeout => 2,
) or die("Cant create socket: $!");
sub smsg { print $socket "PRIVMSG $_[0] :$_[1]\r\n"; }
sub sraw { print $socket "$_[0]\r\n"; }
sraw("NICK $nick");
sraw("USER $ident 8 * :$real");
sraw("JOIN $chan");
while(chomp(my $body = <$socket>)){
if($body =~ /PING(.+)/){ sraw("PONG $1"); }
if($body =~ /$chan :ohai $nick/i){ smsg($chan,"ohai back!"); }
}