in reply to Hash references and efficiency
Generally people write modules for whatever purpose and then only occasionally (if ever) go back and modify them. So use the references in the module and once it's finished, you can write as many programs as you like using %hash and still have efficient code. Here is an example module:
And an example program that uses it:package mylib; use strict; use warnings; use Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw( load_hash ); sub mylib::load_hash { my $href = shift; for (1..1000) { $$href{$_} = $_; } }
#!/usr/local/bin/perl use strict; use warnings; use mylib; my %hash; mylib::load_hash(\%hash); for (keys %hash) { print "key: $_ value: $hash{$_}\n"; }
--Jim
|
|---|