From 08f88032055299df819d17f760bf328fecab034b Mon Sep 17 00:00:00 2001 From: robbie-hatley Date: Tue, 30 Jul 2024 00:01:06 -0700 Subject: Fixed "uninitialized" problem in 280-1. --- challenge-280/robbie-hatley/perl/ch-1.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/challenge-280/robbie-hatley/perl/ch-1.pl b/challenge-280/robbie-hatley/perl/ch-1.pl index 3f63719cf5..81bc5654d4 100755 --- a/challenge-280/robbie-hatley/perl/ch-1.pl +++ b/challenge-280/robbie-hatley/perl/ch-1.pl @@ -55,15 +55,15 @@ Output is to STDOUT and will be each input followed by the corresponding output. use v5.38; use utf8; - no warnings 'uninitialized'; sub second ($x) { my %hash; my $char; for my $idx (0..length($x)-1) { - if ($hash{$char=substr($x,$idx,1)}>0){ + $char = substr($x,$idx,1); + ++$hash{$char}; + if (2 == $hash{$char}){ return $char; } - ++$hash{$char}; } return "\x{FFFD}"; } -- cgit