http://qs1969.pair.com?node_id=131900
Category: Miscellaneous
Author/Contact Info Mephit a.k.a. J. Kufrovich eggie@sunlink.net
Description: This is a script for the XChat IRC client (which happens to use Perl as a scripting language, huzzah!) to handle xdcc stuff: sending files to others automatically as they're requested. The script is mostly subroutines that are completely independent of one another. It does What I Expect, and I know the IRC:: bits are right, but I'm wondering if the Perl can be made any more efficient somehow? I'd appreciate any feedback on this. The code is linked to below. This is my longest Perl program so far, and the first I'm showing to the general public, so please be gentle, OK? Thanks for any tips, folks.
The code is right here.
Replies are listed 'Best First'.
Re: XChat (IRC) XDCC script
by Anonymous Monk on Jan 16, 2004 at 00:28 UTC
    the url dosent exist
Re: XChat (IRC) XDCC script
by Anonymous Monk on Jul 18, 2004 at 23:48 UTC
    if a man speaks in a forrest where no woman is around to hear is he still wrong?
Re: XChat (IRC) XDCC script
by vladb (Vicar) on Dec 19, 2001 at 22:07 UTC
    Hi, I should say your script looks pretty good ;-). Sorry, I didn't have much time to _really_ study into it, but here's what I've found after a quick scan:

    In your xqsend() subroutine, you have the following:
    if ($_[0]) { my $user_index = $_[0]; $user = $xdccqueue[$user_index - 1]{user}; } else { $user = $xdccqueue[0]{user}; #IRC::print("$CX Checking for$CB $user$CX from queue... $CO\n"); }
    First, you don't need to initialize the $user_index variable to simply store the value of the first subroutine argument, considering that the only place you use it is in the line immediately below its initialization.
    Therefore, I'd propose to exchange your if/else block for this:
    $user = $xdccqueue[(($_[0] || 1) - 1)]{user};
    Or, better yet, just use this:
    $user = $xdccqueue[$_[0]]{user};
    since
    (qw(foo bar))[$_[0]]
    would still yield 'foo' when @_ is empty (therefore, $_[0] is undef).

    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith