in reply to mutliplying each element of a list by the same number

for (0..$#ratio_list){ $ratio_list[$_] *= 10; }

This does not filter values that are 0, but does multiply every element of the array by 10. Not sure if you really want to filter zeroes.

Replies are listed 'Best First'.
Re^2: mutliplying each element of a list by the same number
by pc88mxer (Vicar) on May 15, 2008 at 15:58 UTC
    This is just slightly more efficient (at least in terms of keystrokes if not execution time):
    for (@ratio_list) { $_ *= 10 }
    If you wanted to simultaneously create @minutes_list, you can use:
    for (@ratio_list) { ($_ *= 10) && push(@minutes_list, $_) }
      for (@ratio_list) { $_ *= 10 }

      If you're going to do that, why not get rid of useless punctuation altogether?

      $_ *= 10 for @ratio_list;