in reply to Help - I'm a C programmer
I'm not sure what you are trying to do with your code, but lets assuming that the function that you evaluate and manipulate your hash is "change_hash". "change_hash" should return a value, 1 if something changed, or 0 if no changes were made. With that in mind, your basic code should look something like this:
while ( change_hash( \%hash ) ) {}
Within change_hash, you appear to be looking at all the elements, so one way to write this as to return what you need is as follows:
sub change_hash { my $hashref = shift; my $returnflag = 0; foreach my $key ( keys %$hashref ) { if ( change_needed( $key, $$hashref{ $key } ) ) { $returnflag = 1; # do change here } } return $returnflag; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Help - I'm a C programmer
by clintp (Curate) on Jun 17, 2001 at 19:59 UTC | |
by Masem (Monsignor) on Jun 17, 2001 at 21:08 UTC | |
by tilly (Archbishop) on Jun 18, 2001 at 19:29 UTC | |
by John M. Dlugosz (Monsignor) on Jun 18, 2001 at 05:14 UTC | |
by Brovnik (Hermit) on Jun 17, 2001 at 22:55 UTC | |
by Sifmole (Chaplain) on Jun 18, 2001 at 16:21 UTC | |
|
Re: Re: Help - I'm a C programmer
by june_bo (Novice) on Jun 18, 2001 at 00:42 UTC | |
by marcink (Monk) on Jun 18, 2001 at 00:51 UTC |