In article <[EMAIL PROTECTED]>, John W. Krahn wrote:
> Bill Akins wrote:
>>
>> Hi all!
>
> Hello,
>
>> I have this while loop in my script:
>>
>> while (($type ne "Windows") || ($type ne "Linux")) {
>
> Your problem is that you are using or when you should be using and.
>
>
>> print "Enter TYPE of server to build. Linux or Windoze [linux, windows]:
>> \n";
>> $type = <STDIN>;
>> chomp $type;
>> $type =~ tr/a-z/A-Z/;
>> if (($type eq "LINUX") || ($type eq "L")) {
>> $type = "Linux"; }
>> if (($type eq "WINDOWS") || ($type eq "W")) {
>> $type = "Windows"; }
>> }
>
> while ( $type ne 'Windows' and $type ne 'Linux' ) {
> print "Enter TYPE of server to build. Linux or Windoze [linux,
> windows]:\n";
> chomp( $type = ucfirst lc <STDIN> );
> $type = 'Windows' if $type eq 'W';
> $type = 'Linux' if $type eq 'L';
> }
This has tripped me up before. The difference between "while not A AND not
B" and "while not A OR B" I think.
Here's an 'or' version:
my $type1 = '';
while ( $type1 !~ /wisteria|lime/i ) {
print "Enter COLOR of server. Lime or Wisteria [lime, wisteria]: ";
chomp( $type1 = ucfirst lc <STDIN> );
$type1 = 'Wisteria' if $type1 eq 'W';
$type1 = 'Lime' if $type1 eq 'L';
}
--
Kevin Pfeiffer
International University Bremen
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]