in reply to 'my' headache...why doesn't this work?
It's a bit of a hassle, isn't it. I consider this one of perl's warts. You need a temporary to get the job done, which means you have to do something crufty like:
#! /usr/bin/perl -wl use strict; my @nums = qw/ 1 2 3 4 5 /; my $sum = do { my $x; $x += $_ for @nums; $x }; print $sum;
... possibly localizing $_ in the do block. I sort of understand why things are the way they are, but I'm not good enough at internals to be able to explain in a clear manner :)
|
|---|