in reply to reduce line of code

Already mentioned:
my $cmd = $step_no ? $step_no : 0;
Simplifies to:
my $cmd = $step_no || 0;
If $step_no is only false when $step_no is zero, then it can even be simplified to
my $cmd = $step_no;