It should be a multiple-selection as I "declare my variables" ...
- At the top of the relevant enclosure: before option handling; keeping value after a loop;
- Right before their first use: for my $x = 1 if $test is buggy; no other way (search in loop; populating array or hash);
- Inside their first use: preferred
- I just copy what the code already does: in maintenance mode;
- It varies by language: C, C++, SQL