in reply to how can this be improved?

This is mainly superficial, but there are some noteworthy comments.
unless ($^O =~ /aix/) { die ... } # might be better as die ... unless $^O =~ /aix/;
I'm not sure about that whole $recipient thing. Are you expecting an argument?
my $sequence_number = shift || die ...; # technically, you want 'or' instead of '||' here open (ERROR, "/usr/bin/errpt -g -l $sequence_number |"); # you don't check to see if it opened properly... # nor do you ensure the safety of the variable # if I enter '; rm -rf' here, you're in trouble my ($sequence_number) = shift =~ /(\d+)/ or die ...; open ERROR, "/usr/bin/errpt -g -l $sequence_number |" or die "can't run errpt -g -l $sequence_number: $!";
I'm going to idiomatize your while-loop.
while (<ERROR>) { $message{host} = (split)[1], next if /^el_nodeid/; $message{drive} = (split)[1], next if /^el_resource/; $message{detail} = (split)[1], next if /^el_detail_data/; }
Your hex-to-ascii stuff can be replaced by using "H*" instead of "C". The only other thing I'd change is your @mail array and ALL those sprintf()s.
printf SENDMAIL "%-16s: %-20s\n" => @$_ for ["Sequence Number" => $sequence_number], [ Host => $message{host} ], [ Drive => $message{drive} ], [ Model => $message{model} ], [ Microcode => $message{mml} ], [ "Message Type" => $message{type} ], [ "Message Code" => $message{code} ], [ Severity => $message{severity} ], $message{type} eq "SIM" ? ( [ "First FSC" => $message{first_fsc} ], [ "Last FSC" => $message{last_fsc} ], ) : ( [ VOLSER => $message{volser} ], );
It's condensed somewhat, and the data structure still represents the pairing between text and variable. And, if you need to change the format, you change it once.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: how can this be improved?
by blueflashlight (Pilgrim) on Aug 21, 2001 at 22:08 UTC
    >>> die ... unless $^O =~ /aix/;
    I like it. thanks.

    >>>I'm not sure about that whole $recipient thing. Are you expecting an argument?

    The idea is that, if the user wishes to edit the script and change the value of $recipient, then that value will be used, but if not, then "root" will be used. I'll make that clearer in the code and the pod.

    >>> the only other thing I'd change is your @mail array and ALL those sprintf()s.

    thanks! I like that suggestion.