<data file>
coupon_name|distribution_quantity|weight|thickness
gum|235|3|10
toothpaste|500|2|9
dove|559|5|12
shampoo|733|6|6
-----------------------
What i need to accomplish.
The script will be provided with household total that all the above coupons need to be distributed. based on following formula.
For example Household=1000
n=rounddown[1/(dist_quantity/total mailing)]
example for 1st coupon==> 235/1000 = 0.235
1/(235/1000) = 4.255
Round down to lowest number = 4
conclusion 1 in 4 people will get 1st coupon.
coupon 2 == 1/(500/100)=2
-----------------------
This is what i have tried so far.
#! /bin/perl -w
$mailout=1000;
#$data_file = "coupon.list";
#open(data_file) or die("Could not open file!");
while (<>)
{
chomp;
$record=$_;
@fields=split(/\|/,$record);
foreach $line ( @record )
{
//help me loop thru each houshold for each coupon and distribute based on the formula.
}
}
Output results
----------------
household Coupon 1 Coupon 2
1 10 (thickness) 9
2
3 9
4 10 (thickness)
.
.
.
1000
coupon_name|distribution_quantity|weight|thickness
gum|235|3|10
toothpaste|500|2|9
dove|559|5|12
shampoo|733|6|6
-----------------------
What i need to accomplish.
The script will be provided with household total that all the above coupons need to be distributed. based on following formula.
For example Household=1000
n=rounddown[1/(dist_quantity/total mailing)]
example for 1st coupon==> 235/1000 = 0.235
1/(235/1000) = 4.255
Round down to lowest number = 4
conclusion 1 in 4 people will get 1st coupon.
coupon 2 == 1/(500/100)=2
-----------------------
This is what i have tried so far.
#! /bin/perl -w
$mailout=1000;
#$data_file = "coupon.list";
#open(data_file) or die("Could not open file!");
while (<>)
{
chomp;
$record=$_;
@fields=split(/\|/,$record);
foreach $line ( @record )
{
//help me loop thru each houshold for each coupon and distribute based on the formula.
}
}
Output results
----------------
household Coupon 1 Coupon 2
1 10 (thickness) 9
2
3 9
4 10 (thickness)
.
.
.
1000