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:??;


In reply to Re: how can this be improved? by japhy
in thread how can this be improved? by blueflashlight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.