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;'
In reply to Re^3: Initialize variable in BEGIN
by ikegami
in thread Initialize variable in BEGIN
by BillKSmith
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |