#!/usr/bin/perl use strict; use warnings; use Win32; use Win32::DDE::Client; my $favorite = qr/^Slashnet$/o; # favorite network MsgChan("Hello from Perl!", "#perlmonks"); sub GetConn { my $req = new Win32::DDE::Client('mIRC', 'EVALUATE') || Popup("Unable to initiate conversation with mIRC", 16, "DDE Error"); my $conns = $req->Request('$scon(0)'); # how many connections? my $scon; for my $conn (1 .. $conns) { my $network = $req->Request("\$scon($conn).network"); # what network is connection on? if ($network =~ $favorite) { $scon = $conn; last; } } $req->Disconnect; return $scon; } sub MsgChan { my $conn = GetConn(); my $message = shift; my $chan = shift || "#muskrats"; my $mirc = new Win32::DDE::Client('mIRC', 'COMMAND') || Popup("Unable to initiate conversation with mIRC", 16, "DDE Error"); $mirc->Execute ("/scon $conn /msg $chan $message") || Popup("/msg failed", 16, "DDE Execute Error"); $mirc->Disconnect; } sub Popup { my ($msg, $flags, $title) = @_; return Win32::MsgBox($msg, $flags, $title); die $msg; }