From 20182e2e72d7bc6956faf6acc5e8d52eff64b3a9 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Fri, 5 Jul 2019 23:43:12 +0200 Subject: for -> foreach, fix die interpolation msg --- 009/ch2.pl | 2 +- 010/ch2.pl | 2 +- 014/ch2.pl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/009/ch2.pl b/009/ch2.pl index d20def5..fa2a1b0 100755 --- a/009/ch2.pl +++ b/009/ch2.pl @@ -54,7 +54,7 @@ my @points = @ARGV; my $ranks = rank($rank_type, @points); # Display rankings -for my $rank (sort (keys %$ranks)) { +foreach my $rank (sort (keys %$ranks)) { my @positions = @{$ranks->{$rank}}; print "$rank. @positions\n"; } diff --git a/010/ch2.pl b/010/ch2.pl index a5a37f5..1bde152 100755 --- a/010/ch2.pl +++ b/010/ch2.pl @@ -42,7 +42,7 @@ sub jaro { # Count transpositions my $t = 0; - for my $k (keys %matches) { + foreach my $k (keys %matches) { $t += 1 if $k != $matches{$k}; } diff --git a/014/ch2.pl b/014/ch2.pl index 33e3092..628ddf4 100755 --- a/014/ch2.pl +++ b/014/ch2.pl @@ -51,12 +51,12 @@ sub suitable { } # Read words from $DICTPATH and store suitable ones in @suitable_words -open(my $dictd, '<', $DICTPATH) or die 'Unable to open dictionary: $!'; +open(my $dictd, '<', $DICTPATH) or die "Unable to open dictionary: $!"; my @suitable_words = grep suitable, <$dictd>; close($dictd); # Find the longest word(s)... -for my $word (@suitable_words) { +foreach my $word (@suitable_words) { my $len = length $word; if ($len == $max_len) { # ... and print their composition (states) -- cgit v1.2.3