From: martin f. krafft Date: Thu, 9 Sep 2021 10:47:00 +0000 (+0200) Subject: Iterate array using references, not indices X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=56c719b65fc1030c61f0afba34ca36089e531d17;p=irssi-scripts.irssi.org.git Iterate array using references, not indices Still learning my Perl… Signed-off-by: martin f. krafft --- diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index 7ac2b99..74464f2 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -307,12 +307,12 @@ sub get_win_threshold { sub print_levels_for_all { my ($type, @arr) = @_; - info("$type mappings:"); - for (my $i = 0; $i < @arr; $i++) { - my $name = $arr[$i]->{'name'}; - my $net = $arr[$i]->{'server'}->{'tag'} // ''; + info(uc("$type mappings:")); + for my $i (@arr) { + my $name = $i->{'name'}; + my $net = $i->{'server'}->{'tag'} // ''; my ($t, $tt, $match) = get_specific_threshold($type, $name, $net); - my $c = ($type eq 'window') ? $arr[$i]->{'refnum'} : $arr[$i]->window()->{'refnum'}; + my $c = ($type eq 'window') ? $i->{'refnum'} : $i->window()->{'refnum'}; info(sprintf("%4d: %-40.40s → %d (%-8s) match %s", $c, $name, $t, $tt, $match)); } }