in reply to reduce line of code
This is probably what you're after.
my $cmd = $step_no || 0; # If $step_no is 0, it assigns... uh, 0 over it.Note that if you're accepting user input, like $step_no = param("step") or something you should validate all user parameters before using them in other code. Perhaps-
my $cmd = $step_no =~ /\A\d+\z/ ? $step_no : 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reduce line of code
by ysth (Canon) on Jul 14, 2009 at 06:36 UTC | |
by lima1 (Curate) on Jul 14, 2009 at 08:52 UTC | |
by jeanluca (Deacon) on Jul 14, 2009 at 09:26 UTC |