in reply to how can this be improved?

Nice job, imho, but allow me two random remarks:

-- Hofmator

Replies are listed 'Best First'.
Re: Re: how can this be improved?
by busunsl (Vicar) on Aug 21, 2001 at 14:17 UTC
    $recipient = "root" unless (defined($recipient));

    Or even shorter with this common idiom:
    $recipient ||= "root";

      Those are not the same statement. The first only sets $recipient to "root" if $recipient is undef. The second sets it if $recipient is "" or 0, as well.

      One big suggestion I have is to break things out into functions and put those functions in a module. Use that module and your script becomes much smaller. But, that's not the big savings. Say, for instance, you want to do something similar, but not quite the same. You just re-use a bunch of functions and your development time is cut dramatically. In addition, you already know that the funtions in this module are debugged correctly, so you can trust them! :)

      ------
      /me wants to be the brightest bulb in the chandelier!

      Vote paco for President!

        thanks for the suggestion ... I thought of doing it in modules, but because of the way that it will be used, I decided that it would be more robust if it was self-contained. (Perhaps that isn't a good decision; time will tell :-)
Re: Re: how can this be improved?
by blueflashlight (Pilgrim) on Aug 21, 2001 at 22:01 UTC
    The idea behind the ...

    my $recipient = "root"; unless (defined($recipient)) { $recipient = "root" }

    is that, if the user chooses not to edit the script and put their email address in the var $recipient, the mail would go to root by default. I guess my execution of that idea leaves something to be desired.

    Thanks much for the regex/pack/substr reduction ... I was sure that there was a way to do that, but I just couldn't figure it out!