>>>>> "JLC" == Joseph L Casale <jcas...@activenetwerx.com> writes:

  >> nothing HAS to be global. you can pass it to a sub, you can store the
  >> options in a hash (my way and easy with getopt::long), etc. some globals
  >> may be useful but always using them or not know other ways is bad.

  JLC> Ok, fair enough.

that is true for all programming, not just perl.

  JLC> Well the rest of the code _only_ does the telnet part and has too much
  JLC> hardcoded stuff atm. It works perfectly as per cpan docs.

so it could still likely use a review. especially if you are learning
perl. many doc examples aren't written to the best coding standards.

  JLC> I think I have it:

  JLC> sub parse_output {
  JLC>         my ( $string, $match ) = @_;

better.
  JLC>         die "Error in parse_output sub\n" unless ((defined $string) || 
(defined $match));

don't put the \n in the die string so it will report the line number
too. and your boolean test is wrong. you want both to be defined. and
even defined is overkill if you know you have text and a match
string. unless either is just '' or '0' they will be true. so that line
can be:

        die "Error in parse_output sub" unless $string && $match ;

  JLC>         if ( $string =~ /$match/ ) {
  JLC>                 return "OK";
  JLC>                 } else {
  JLC>                         return "CRITICAL";
  JLC>                 }

that is a very odd indent style. the returns should be indented the
same. the }else and close should be left indented one more. like this:

        if ( $string =~ /$match/ ) {
                return "OK";
        }
        else {
                return "CRITICAL";
        }


  JLC> $status = parse_output($output, $expect);
  JLC> print "Status: $status\n";

  >>> From what I can see, this follows all the suggestions you have provided?

and there are more! always more. :)

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to