plevine has asked for the wisdom of the Perl Monks concerning the following question:
Trying to do it right - My script uses symbolic references. I'd like to know how change it so that I'm using hard references and can use 'use strict' without errors.
The program receives a hash of hashes and then attempts to update the hash after the record has read.
my %hash=('1'=>{one=>""}, '2'=>{two=>"",zwei=>"",dos=>""}, '3'=>{three +=>"",tres=>""},'4'=>{four=>""},'5'=>{five=>""},6=>{six=>"",seis=>""}, +7=>{seven=>""}); my %subs; my $href; my $valCount=0; my $recCount=0; #get number of items foreach my $item (keys %hash) { print "count is " . (keys %{$hash{$item}}) . "\n"; $valCount+= (keys %{$hash{$item}}); } while($valCount > 0) { foreach my $id (sort keys %hash) { if(! exists $subs{$id}) { $href=$hash{$id}; foreach my $word (sort keys %$href) { next if(exists $$href{$word}{written}); $valCount--; print "$id $word\n"; $subs{$id}=""; $href->{$word}={written=>1}; last if((keys %{$hash{$id}}) > 1); } $recCount++; if($recCount == 4) { $recCount=0; %subs=(); } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: desire hard ref alternative
by choroba (Cardinal) on Aug 15, 2014 at 22:36 UTC | |
by plevine (Initiate) on Aug 15, 2014 at 22:47 UTC | |
|
Re: desire hard ref alternative
by Anonymous Monk on Aug 15, 2014 at 22:20 UTC | |
by choroba (Cardinal) on Aug 15, 2014 at 22:38 UTC | |
by Anonymous Monk on Aug 16, 2014 at 00:33 UTC |