#!/usr/bin/perl

use strict;


main();

sub main {




    ##if/else are generally used as testing loops.

    #If some number is greater than 10, do something to it. Otherwise(else) do something else.

    my $val = 15;

    print "\nSimple if/else Example:\n\tOriginal Value is: $val\n";
    
    #if the value is > or = to 10, we execute the first block of text.
    #otherwise we execute the 'else' block.
    if ($val >= 10) {
	print "\tval is greater than or equal to 10... subtract 2\n";
	$val = $val - 2;
    } else {
	#the value is < 10, do nothing.
	print "\tVal is less than 10 do nothing!\n";
    }

    print "\n\nNew value is: $val\n\n--------------------------------\nTwo if blocks\n";



    #these if loops can be concatenated... but be careful!

    #Two distinct if looks will always execute
    if ($val > 5) {
	print "~~~ Is greater than 5\n";
    }

    if ($val > 10) {
	print "~~~ Is greater than 10!\n";
    }

  print "\n\n--------------------------------\nMultiple joined if_else blocks\n";

    #when you join if statements together, the if tests stop after the FIRST
    #  test of truth passes....
    #OR the else block is hit...
    #OR the if/else loops end...
    if ($val > 5) {
	print "xxxxVal > 5!\n";
    } elsif ($val > 10) {
	print "xxxx val > 10!\n";  #notice you won't ever reach this!!! DANGER!
    } else {
	print "----- Value not > 5 or 10\n\n";
    }

    
}

