Skip to content

Commit

Permalink
Merge pull request #277 from jrha/each_is_evil
Browse files Browse the repository at this point in the history
Replace four instances of while-each with foreach
  • Loading branch information
jrha authored Sep 9, 2024
2 parents f50b380 + 8010334 commit dc22c83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/perl/ReporterMany.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ sub _rep_setup
# initialise with current "global" CAF::Reporter settings
# if DEBUGLV is not set
if (! exists($self->{$DEBUGLV})) {
while (my ($opt, $val) = each (%$CAF::Reporter::_REP_SETUP)) {
$self->{$opt} = $val;
foreach my $opt (keys %{$CAF::Reporter::_REP_SETUP}) {
$self->{$opt} = ${$CAF::Reporter::_REP_SETUP}{$opt};
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/perl/TextRender.pm
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ sub _initialize
STRICT => $DEFAULT_TT_STRICT,
RECURSION => $DEFAULT_TT_RECURSION,
};
while (my ($key, $value) = each %{$opts{ttoptions}}) {
$self->{ttoptions}->{$key} = $value;
}
foreach my $key (keys %{$opts{ttoptions}}) {
$self->{ttoptions}->{$key} = $opts{ttoptions}{$key};
};

# set render method
($self->{method}, $self->{method_is_tt}) = $self->select_module_method();
Expand Down Expand Up @@ -520,7 +520,8 @@ sub render_tiny

my $c = Config::Tiny->new();

while (my ($k, $v) = each(%{$self->{contents}})) {
foreach my $k (keys %{$self->{contents}}) {
my $v = $self->{contents}{$k};
if (ref($v)) {
$c->{$k} = $v;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/test/perl/exception.t
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ my $opts = {};
my $success_func = sub {
my ($arg1, $arg2, %opts) = @_;
push(@$args, $arg1, $arg2);
while (my ($k, $v) = each %opts) {
$opts->{$k} = $v;
foreach my $k (keys %opts) {
$opts->{$k} = $opts{$k};
};
return 100;
};
Expand Down

0 comments on commit dc22c83

Please sign in to comment.