Perl: the Markov chain saw | |
PerlMonks |
Re: Functions in Perlby TomDLux (Vicar) |
on May 23, 2004 at 04:20 UTC ( [id://355687]=note: print w/replies, xml ) | Need Help?? |
Modern practice is to make variables as local as possible. Creating a routine to initialize global variables is totally contrary to modern practice. As much as possible, functions/routines should only manipulate data and variables they recieve as arguments. As well, initializing an array to an empty array is pointless, as is initializing a strting to an empty string, or an integer to zero ... they are all created witht he value undef, which in many situations has the effect you assign explicitly. Admittedly, in certain odd situations, it becomes essential to assign a value to avoid pointless warning messages, but assigning routine intial values is a C practice, made obsolete by C++, Java and Perl. As far as your printarg is concerned, it looks fine to me. However (You knew there was a however coming, didn't you?) the instructions only say to number the args, no comment about starting at zero or one or 17425. I would use that to my advantage to use the automatic numbering system of an array:
I was quick to learn $#array, took me a lot longer to learn 'scalar @array .... both are useful. </code>--
In Section
Seekers of Perl Wisdom
|
|