Alwanza Home UW Linux Administration
#!/usr/bin/perl

use strict;

print "\nDemonstrate how || and && work\n\n";

my $secondChoice = "true";

for (1 .. 2) {
    my $firstChoice = 1;

    print qq|
Example $_ a: First Choice is $firstChoice
              Second Choice is $secondChoice|;
    # this is one way to pass variables to a subroutine
    &test_me($firstChoice, $secondChoice);

    $firstChoice = 0;
    print qq|

Example $_ b: First Choice is $firstChoice
          Second Choice is $secondChoice|;
    # this is one way to pass variables to a subroutine
    &test_me($firstChoice, $secondChoice);
    print "\n\n";
    
    $secondChoice = "false";
}

exit 0;

#**********************
sub test_me {
    # this is one way to pass variables to a subroutine
    my ($firstChoice, $secondChoice) = @_;

    my $Or_result = $firstChoice || $secondChoice;
    my $And_result = $firstChoice && $secondChoice;

    print "\n\n code: Or_result = firstChoice || secondChoice\n";
    print " Or_result = $Or_result\n\n";
    print " code: And_result = firstChoice && secondChoice\n";
    print " And_result = $And_result\n";
}

#*********** END *********