#!/usr/bin/perl

use strict;


main();

sub main {



######Assignment Operators
    print "Assignment Operators\n";

    #my will set this variable at the scope the my is found in... this variable will be accessible by all  bracketed code within this bracketed section(GLOBALS are seperate).

    my $val = "some thing";

    print "###Assignment\nWe have assigned \'\$val\' to: \'$val\'\n###\n";



###Relational Operators

    #all of the standard operators to compare 2 values work: > < <= >= == != <=>

    my $val1 = 10;
    my $val2  = 300;

    print "###Relational\n";

    if ($val1 < $val2) {
	#do something
	print "$val1 is lessthan $val2\n";
    } else {
	#	do something else
	print "$val1 is not less than $val2\n";
    }
    print "###\n";

###Aritmetic Opers

    print "###Artihmetic\n";

    #+ - * /  all work on numbers.

    my $val3 = 50;
    my $val4 = 5;
    my $res = $val3 / $val4;

    print "$val3 / $val4 == $res\n";

    my $zero = 0;

    print "###\n";

    ###   print "10/0 is?" . 10/$zero . "\n"; #some errors are thrown if an illegal operation is attempted...uncomment the operation and run the script.


###Logical operators

#and (&&)
#or (||)
#not (!)
#xor (^) 
    print "###Logical Opers\n";

    ##simple example of AND / OR using 0 and 1 as boolean
    if (1 and 0) {
	print "if both are true will not go here\n";
    } else {	
	print "if either are not true will go here\n";
    }
    print "  --\n";
    if (1 or 0) { #also if (0 or 1) {
	print "If one or both are true will go here\n";
    } else {
	print "If both are false will  go here\n";
    }
    print "  --\n";

    
    ##You can create more complex tests also
    my $val1 = 10;
    my $val2 = 33;
    my $letter = "A";
    my $another_letter = "A";

    #like in building equations, the operations contained in the deepest ()
    #will be evaluated first.
    #ie:  ($val1 < $val2) is evaluated and it returns true or false
    #     ($letter eq $another_letter) is then evaluated and returne true/false
    #finally the 2 returned true or false values returned are compared with 
    #the 'and' statement
    if (($val1 < $val2) and ($letter eq $another_letter)) {
	print "will get here if both are true\n";
    } else {
	print "will get here if one or both are false\n";
    }
    


    print "###\n";

}

