attn2risky
IS-IT--Management
Hi all, I've just been introduced to PERL and am looking for advice on the following snippet of code. I want to have the $TotalDemandData be a result of the input variables it already is (this works) and the new BOH data (which I named $BOHSub) subtract the Total Demand and then ONLY print the result if it's above zero.
#!/opt/perl/bin/perl -w
system "rm -f ./new_forecastsales.out";
open (NEW, ">>new_forecastsales.out");
open (MATRIX, "matrix.out");
#<MATRIX>;
while (<MATRIX>) {
@fields = split (/,/);
$Enterprise = $fields[0];
$Site = $fields[1];
$Item = $fields[2];
$ForecastCount = $fields[3];
$ForecastAvg = $fields[4];
$SalesCount = $fields[5];
$SalesAvg = $fields[6];
$BOH = $fields[7];
$TotalDemandData = "$ForecastCount" * "$ForecastAvg" + "$SalesCount" + "$SalesAvg";
$BOHSub = "$BOH" - "$TotalDemandData";
if ($BOHSub > 0)
{
print NEW $BOHSub;
}
else
{
print NULL; #this is obviously wrong
}
print NEW $Enterprise, ",", $Site, ",", $Item, ",", $BOHSub, "\n";
}
close (MATRIX);
close (NEW);
my main issue is, how do i get the "else" statment to print nothing(or simply...leave that line out in the final print statement)?
i'm very new so i tried to put in as much detail about my problem as possible. thanks so much!!
#!/opt/perl/bin/perl -w
system "rm -f ./new_forecastsales.out";
open (NEW, ">>new_forecastsales.out");
open (MATRIX, "matrix.out");
#<MATRIX>;
while (<MATRIX>) {
@fields = split (/,/);
$Enterprise = $fields[0];
$Site = $fields[1];
$Item = $fields[2];
$ForecastCount = $fields[3];
$ForecastAvg = $fields[4];
$SalesCount = $fields[5];
$SalesAvg = $fields[6];
$BOH = $fields[7];
$TotalDemandData = "$ForecastCount" * "$ForecastAvg" + "$SalesCount" + "$SalesAvg";
$BOHSub = "$BOH" - "$TotalDemandData";
if ($BOHSub > 0)
{
print NEW $BOHSub;
}
else
{
print NULL; #this is obviously wrong
}
print NEW $Enterprise, ",", $Site, ",", $Item, ",", $BOHSub, "\n";
}
close (MATRIX);
close (NEW);
my main issue is, how do i get the "else" statment to print nothing(or simply...leave that line out in the final print statement)?
i'm very new so i tried to put in as much detail about my problem as possible. thanks so much!!