> Kevin der Kinderen <[EMAIL PROTECTED]> said:
> Thanks for the comments Smoot.
>
> I thought "while (<>) {...}" was the same as "foreach (<>) {...}". Is this
> because foreach provides a list context to the file being read and while
> provides scalar context? I read this in the camel book but didn't understand
> the significance. It makes a difference when the list is large?
Correct. List vs scalar context.
> Without the if statement in the code, if the last line is blank then I get
> something like this as a return...
>
> vaugw001 is reachable.
> vadgw001 is reachable.
> oh3gw001 is reachable.
> tx88gw001 is NOT reachable. #done on purpose
> is NOT reachable.
>
> Could I be looking at the blank line differently or be more careful with the
> input file format?
You could add code to check for an empty line. Something like:
next if /^\s*$/;
which will skip empty lines. Also it is convenient to skip perl style
comments, so you can annotate the input. A line like:
next if /^#/;
Regular expressions are you friend.
>
> Finally, is this the only way to run this script for a single host?
>
> echo vaugw001 | live
With the way <> works, yes. You can, of course add an option to take a single
host as a command line argument and handle the single host case as a special
case.
--
Smoot Carl-Mitchell
Consultant
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]