John Krahn wrote: > Debbie Cooper wrote: > > my @empty = (); > > my @headings = (); > > Aggregate variables created with my() are empty by default so assigning an > empty list to them is redundant. >
I hope I am not opening a can of worms by getting into a style disucssion, and I will preface this entire thread with: Style is a personal issue; pick one that works for you and be consistent but not dogmatic. The style must serve you; you do not serve the style. Read good code, and incorporate stylistic idiom that suits the task at hand. I used to be in the habit of always explicitly assigning to EVERY variable I used upon declaration, and when declaring a variable that I will use for a hashref or listref, I still do explicitly assign. # instantiate a hasref to hold data about some person my $person = {}; # instantiate a listref to hold my family my $people = []; $person->{hair} = 'blond'; $person->{name} = 'Lawrence'; $people->[0] = $person; Of late, I have gotten out of the habit of explicitly initializing lists or hashes, but I can see doing that piece of extraneous code to reinforce in the users mind that the list/hash is starting out virginal. More often, I defer the declaration of the lexical variable until I have the list or hash elements available, so I never declare them as empty. my $person = { hair => 'blond', name => 'Lawrence' } ; my $people = [ $person ] ; Obviously the solution that elides the intermediate $person variable should be leaping to every reader's mind now. my $people = [ { hair => 'blond', name => 'Lawrence } ] ; But these are the stylistic differences that serve to distinguish the masters from the aprentices. One begins by teaching the novice the straightforward but verbose technique, and later the shortcuts. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>