in reply to dynamically referenced hashes ... editing
Per kennethk's reply, what you have might be more conscisely written (assuming use warnings; and use strict;) as:
Or even as:my @interfaceref_array; for my $name (@list_of_junk) { my $hash_ref = { # curly brackets enclose junk_name => $name, # quotes not needed two => result_of_function($name), }; do_some_stuff(); $hash_ref->{three} = "toilet"; # quotes needed for value push @interfaceref_array, $hash_ref; }
my @interfaceref_array; for my $name (@list_of_junk) { my %hash = ( # parentheses enclose junk_name => $name, two => result_of_function($name), ); do_some_stuff(); $hash{three} = "toilet"; push @interfaceref_array, \%hash; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dynamically referenced hashes ... editing
by chrishowe (Acolyte) on Jan 28, 2009 at 09:55 UTC |