in reply to Re^2: Getting a result from "foreach" block
in thread Getting a result from "foreach" block

Then why not:

my @results; foreach (@data) { push @results, $_ * 13; }

To avoid the mutation of @data ?

Replies are listed 'Best First'.
Re^4: Getting a result from "foreach" block
by AnomalousMonk (Archbishop) on Jun 26, 2014 at 18:31 UTC

    Better, IMHO, is  my @result = map $_ * 13, @data; as already suggested by AppleFritter and CountZero. (Better because more concise and expressive, and it just leaves  $_ the heck alone.)