2D Scan, Flipping the Scan Direction

MOT1 is scanned at different positions of MOT2. MOT1 is scanned from 5 to 10 and then from 10 to 5 reverting the direction.

#!/usr/bin/perl -w
#
use strict; 
my $status = 1; 
#
# the outer loop motor and its positions
#
my $mot_2d = "mot27"; 
# my @pos_2d = qw( 10 20 30);
my @pos_2d = map {$_ = $_*0.1 + 0.3}  ( 0 .. 2);
#
#
#
my $start = -2;
my $stop = -1.9;
my $st =  0.1;  # sample time

my $bl = Spectra::get_motor_unit_backlash( "mot30"); 
Util::log( "mot30, set backlash to 0, was $bl"); 
Spectra::set_motor_unit_backlash( "mot30", 0.); 

foreach my $pos_2d ( @pos_2d)
{
    if( !Spectra::move( $mot_2d => $pos_2d))
    {
        $status = Spectra::error( "failed to move $mot_2d");
        goto finish;
    }
    #
    # inner loop: mot30
    #
    Util::log( "execute a mot30 scan, from $start to $stop "); 
    if( !Spectra::scan( type => "motor", 
                        device => "mot30", 
                        start => $start,
                        stop => $stop,
                        delta => 0.01,                 # step width 
                        st => $st,                  # sample time
                        comment => "$mot_2d at $pos_2d"))
    {
        $status = Spectra::error( " Failed to scan ");
        goto finish;
    }
    #
    # this statement reverses the scan direction 
    #
    ( $start, $stop) = ( $stop, $start); 
}
finish:
Util::log( "mot30, set backlash to $bl"); 
Spectra::set_motor_unit_backlash( "mot30", $bl); 
$status;