rsiedl has asked for the wisdom of the Perl Monks concerning the following question:
the script:package MeSH::KOL; use strict; use vars qw($VERSION); $VERSION = '0.01'; sub new { my ($class) = @_; my $self = {}; $self->{KOLS} = (); bless $self, $class; return $self; } # end-sub sub build_KOL { my($self) = @_; # for this example my %results = (); $results{1} = "blah1"; $results{2} = "blah2"; $self->{KOLS} = %results; } # end-sub sub get_all_KOLS { my ($self) = @_; return $self->{KOLS}; #my %hash = (); #$hash{1} = "blah1"; #$hash{2} = "blah2"; #return %hash; } # end-sub
This outputs 72/128 =#/usr/bin/perl use MeSH::KOL; my $kol_q = new MeSH::KOL; $kol_q->build_KOL; my (%kols) = $kol_q->get_all_KOLS; foreach my $auth_id (keys %kols) { print "$auth_id = $kols{$auth_id}\n"; } # end-foreach
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hashes in Perl Modules
by merlyn (Sage) on Jan 20, 2005 at 16:09 UTC | |
|
Re: Hashes in Perl Modules
by Fletch (Bishop) on Jan 20, 2005 at 16:10 UTC | |
|
Re: Hashes in Perl Modules
by osunderdog (Deacon) on Jan 20, 2005 at 16:20 UTC | |
|
Re: Hashes in Perl Modules
by holli (Abbot) on Jan 20, 2005 at 16:12 UTC | |
|
Re: Hashes in Perl Modules
by borisz (Canon) on Jan 20, 2005 at 16:15 UTC | |
|
Re: Hashes in Perl Modules
by Mutant (Priest) on Jan 20, 2005 at 16:15 UTC | |
|
Re: Hashes in Perl Modules
by macPerl (Beadle) on Jan 20, 2005 at 21:58 UTC |