metaperl has asked for the wisdom of the Perl Monks concerning the following question:
But in the following program:
we see that %map does not end up having all the various values that were tested via the expression while ($map->{$start})#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; sub find_numbers { my ($amount, $map)=@_; my $start = 11; my @found; while ($amount--) { while ($map->{$start}) { ++$start; } push @found, $start++; } @found; } my %map = ( '11' => 1, '12' => 1, '15' => 1,); my @free_numbers = find_numbers(4, \%map); die Dumper(\@free_numbers, \%map);
Why is that?
-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: When testing for certain hash positions as non-zero, why werent the test positions set to empty string?
by ikegami (Patriarch) on Aug 23, 2010 at 15:31 UTC | |
|
Re: When testing for certain hash positions as non-zero, why werent the test positions set to empty string?
by moritz (Cardinal) on Aug 23, 2010 at 14:54 UTC | |
|
Re: When testing for certain hash positions as non-zero, why werent the test positions set to empty string?
by BrowserUk (Patriarch) on Aug 23, 2010 at 14:55 UTC | |
by JavaFan (Canon) on Aug 23, 2010 at 15:01 UTC |