# this works as a bash include
#
#COMM Math::Range, operational methods
#COMM - range and point
#COMM - range and range
#
perl -e '
   use strict;
   use lib shift();  # give include precedence to code directory, perl -I would not work!
   use Math::Range;
   my ($r1,$r2);
   $r1=Math::Range->new(1,2);
   $r2=Math::Range->new([1.5,undef]);
   range_pairtests($r1,$r2);
   $r2->lower(undef);
   range_pairtests($r1,$r2);
   $r1=Math::Range->new_parsed(q(2..107));
   $r2=Math::Range->new_parsed(q(2..84));
   range_pairtests($r1,$r2);
   sub range_out {
     my $r=shift;
     printf "range %s\n", $r->string();
   }
   sub range_pairtests {
     my ($r1,$r2)=@_;
     range_out($r1);
     range_out($r2);
     printf " ranges overlap: %d\n", $r1->overlaps($r2);
     printf " range 1 includes 2: %d\n", $r1->includes($r2);
     printf " range 2 includes 1: %d\n", $r2->includes($r1);
     printf " ranges crossed: %s\n", $r1->cross($r2)->string();
   }
 ' -- $dircode
