in reply to Re^2: Initialize variable in BEGIN
in thread Initialize variable in BEGIN
I wasn't saying that BEGIN is never useful. I was talking about in the situation at hand.
But even in your entirely different scenario, does it really make sense?
perl -nle'BEGIN { $prod = 1; } $prod *= $_; END { print $prod; }'
vs
perl -le'$prod = 1; $prod *= $_ while <>; print $prod;'
|
|---|