[ABE.pm] My first enclosure doesn't work. :-(

Ted Fiedler fiedlert at gmail.com
Fri Oct 26 11:05:55 PDT 2007


Aside from doing the calculations - I would go with an approach something
like this. Im in a meeting so I didn't have time to work the calculations
in...

Ted

___ Code Below ___

#!/usr/bin/perl
use strict;
use warnings;

sub make_if_elsif {
#  This is the code we are trying to emulate with our enclosure
my $capt = shift;

#personally I would use something like this, but thats neither here nor
there :)
#return qq
#|( $capt < 100 )                          ? '3.0' :
#( ($capt >= 100) and ($capt < 250) )     ? '1.5' :
#( ($capt >= 10000) and ($capt < 50000) ) ? '0.01' :
#'0.00'|;

return qq|
  if ($capt eq "") {return (0.0);}
  elsif ($capt < 100)
    {return (3.0);}
  elsif (($capt >= 100) && ($capt < 250))
    {return (1.5);}
  elsif (($capt >= 250) && ($capt < 500))
    {return (1.0);}
  elsif (($capt >= 500) && ($capt < 750))
    {return (0.75);}
  elsif (($capt >= 750) && ($capt < 1000))
    {return (0.5);}
  elsif (($capt >= 1000) && ($capt < 2500))
    {return (0.25);}
  elsif (($capt >= 2500) && ($capt < 5000))
    {return (0.15);}
  elsif (($capt >= 5000) && ($capt < 7500))
    {return (0.05);}
  elsif (($capt >= 7500) && ($capt < 10000))
    {return (0.025);}
  elsif (($capt >= 10000) && ($capt < 50000))
    {return (0.01);}
  elsif ($capt >= 50000)
    {return (0.005);}\n|;

}


my %costCalcH = ( "50000" => 0.005,
                  "10000" => 0.01,
                  "7500 " => 0.025,
                  "5000 " => 0.05,
                  "2500 " => 0.15,
                  "1000 " => 0.25,
                  "750  " => 0.5,
                  "500  " => 0.75,
                  "250  " => 1.0,
                  "100  " => 1.5,
                  "0    " => 3.0,
                 );


# if you print out $stmt, you get the if-elsif statment above.


my $x = make_if_elsif(300);
print $x ;

$x = make_if_elsif(5000);
print $x ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/abe-pm/attachments/20071026/f31ca04b/attachment.html 


More information about the ABE-pm mailing list