sacky0003
sacky0003

Reputation: 25

Can't print the inital number in perl

My Perl code is not executed from the initial number.

#!/usr/bin/perl -w

print "SrepAring inpCKut filYes\n";

$incr=0.25;
$dist=3.0;
$inti=3.0;

my $filename = 'job-1.sh';

open (my $BATCHFILE, '>', "$filename");

while ($dist < 15) {
    $dist += $incr;
    $inti = $dist - 0.25;
    print $BATCHFILE
"
YOYO -O -i min_mdin.$dist -o min_mdout.$dist -p TATA -c prod.rst.$inti -r min.rst.$dist
"
}

close ($BATCHFILE);
YOYO -O -i min_mdin.3 -o min_mdout.3 -p TATA -c prod.rst.2.75 -r min.rst.3

YOYO -O -i min_mdin.3.25 -o min_mdout.3.25 -p TATA -c prod.rst.3 -r min.rst.3.25

YOYO -O -i min_mdin.3.5 -o min_mdout.3.5 -p TATA -c prod.rst.3.25 -r min.rst.3.5

Upvotes: 0

Views: 64

Answers (1)

choroba
choroba

Reputation: 241968

If you want to print the value before it changes, put the print before the assignment.

while ($dist < 15) {
    print $BATCHFILE "\nYOYO -O -i min_mdin.$dist -o min_mdout.$dist -p TATA -c prod.rst.$inti -r min.rst.$dist\n";
    $dist += $incr;
    $inti = $dist - 0.25;
}

Upvotes: 2

Related Questions