Depends on many things as to how "efficient" you can get . Here's one possibility:
my @envars; push @envars,{ value => 23, description => 'temperature in Celsius' }, { value => 56, description => 'relative humidity in %' } +, { value => 1008.1, description => 'pressure in millibars +' }, { value => 4, description => 'dewpoint in degrees Celsiu +s' }, { value => 344, description => 'total column ozone in Do +bson Units' };
You could do better by not repeating the text "value" and "description" several times.
# say you've got 2 parallel arrays @values and @descriptions my @envars = map({ value => $values[$_], description => $descriptions[ +$_] }, 0..$#values);
Or perhaps you really want to just push them onto the array rather than clobbering it each time...
# Same assumption as before ... for my $i (0..$#values) { push @envars, { value => $values[$i], description => $descriptions[$ +i] }; }
In reply to Re: Populating an Array of Referenced Values
by duff
in thread Populating an Array of Referenced Values
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |