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

map

my @minutes_list = grep $_ != 0, map $_ * 10, @ratio_list;

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: mutliplying each element of a list by the same number
by almut (Canon) on May 15, 2008 at 17:23 UTC

    or

    my @minutes_list = map $_*10 || (), @ratio_list;

    (There's nothing at all wrong with your solution. I just wanted to point out an often overlooked feature of map ... that is, it can return a list shorter than the input list, if you have the expression evaluate to the empty list for the elements to be dropped.)