There's a more compact third form which does it all in one line,
(with the oblig firework about $a and $b sacred to sort).sub function { my ($a,$b,$c,$d) = (1,2,3,4); }
All of them are functionally equivalent, perhaps differing a mite in how they are optimized.
There are two schools about where to declare. The C school puts declarations right after their scope is opened. That is necessary in C, and people used to that like having all the variables listed in one place. The other way is to postpone until you have enough information to declare and initialize at the same time.
It is largely a matter of style. Choose one you like and stick with it.
Update: Fletch++, good point!
After Compline,
Zaxo
In reply to Re: Question on use of 'my'
by Zaxo
in thread Question on use of 'my'
by nmerriweather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |