The goto is ugly and very probably not at all necessary. I'll assume a sub cleanup() for the moment. For some reason, you chose to only test if $metastat exists, and then you don't use it in ExecCmd. I'll assume you have a good reason for that.

The exercise is to spot the differences yourself.

use strict; # first. use NetIQ::Nqext; my $sev_fail = 10; my $metastat = "/usr/sbin/metastat"; my $resmsg = ""; -e $metastat or cleanup; # Assuming 0 also indicates failure: NetIQ::Nqext::ExecCmd("metastat|grep State:|grep -v Okay") or cleanup; my $results = NetIQ::Nqext::ExecCmd("metastat"); # Where does $do_event come from and why isn't it just a simple boolea +n? if ($do_event eq "y") { NetIQ::Nqext::CreateEvent( $severity, "Disksuite Disk(s) Need Attention", $Akpid, # capital A? $resmsg, 0, # description of the parameter (one word will suff +ice) $results, "", # description 0, # description 0 # description ); }
If you do not have a sub cleanup(), you can still avoid using the ugly goto LABEL by putting this code in a bare block (which is a loop that runs one time).
use strict; # first. use NetIQ::Nqext; my $sev_fail = 10; my $metastat = "/usr/sbin/metastat"; my $resmsg = ""; { -e $metastat or last; # Assuming 0 also indicates failure: NetIQ::Nqext::ExecCmd("metastat|grep State:|grep -v Okay") or last +; my $results = NetIQ::Nqext::ExecCmd("metastat"); if ($do_event eq "y") { NetIQ::Nqext::CreateEvent( ... ); } }

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }


In reply to Re: netiq metastat by Juerd
in thread netiq metastat by JSchmitz

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.