in reply to Re: unblessed reference problem
in thread unblessed reference problem

I forgot to mention that you can use a continuation closure, something like this (untested):

my $test = sub { my $hr=shift; return $hr->{$var1}{$var2} }; foreach my $domain (sort {$a cmp $b} keys %{$hash}) { my $value = &{$test}($$hash{$domain}); }

...roboticus

Update: correction, as noted by chromatic. (I didn't make the other change, as it's merely ugly rather than wrong, and chromatic shows the nicer looking version anyway.)

Replies are listed 'Best First'.
Re^3: unblessed reference problem
by chromatic (Archbishop) on Mar 26, 2010 at 18:55 UTC

    Two small nits. First, that isn't a continuation. It's a closure. (It closes over variables, not control flow.)

    Second, your dereferencing syntax could be much clearer:

    my $value = $test->($hash->{$domain});