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

  >> use a named variable with foreach loops. sure some docs and examples
  >> show using the default $_ but it can have problems with action at a
  >> distance. also a name makes the code read better.

  JLC> Ok, simple enough to do.

  >> and where does $match get set? it must be from outside the sub so it is
  >> a global. bad!

  JLC> Well $match comes from Getopt::Long, it has to be global, no? Now I'm 
confused:)

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.

  >> same with status. either declare it locally and return it or do
  >> something else but don't set globals just to mark something as ok

  JLC> Soon after posting I realized it was cleaner to return the value...

  >> more code and data. use Data::Dumper to show exactly what you are
  >> passing in.

  JLC> I used Data::Dumper to see what was actually being passed and it takes
  JLC> the following form:

  JLC> $VAR1 = 'system status
  JLC>        system status: Normal

  JLC> hostname';

  JLC> Sorry for the noobish question, but I am not sure how to interpret this?
  JLC> I assumed this was 4 lines of text, but I guess not?

no. it is a single string with 4 lines in it. why would you think
foreach would loop over its lines vs its single string? arrays can
contain strings without lines and a scalar could contain a single string
with lines. so foreach is neutral and just loops over what you pass it
in terms of perl elements. if you want lines, split them yourself or get
them some other way. e.g. backticks in a list context will split its
output into lines for you. i dunno how you are doing this telnet thing
(as i said SHOW MORE/ALL CODE :).

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