diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-06-13 18:39:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-13 18:39:39 +0100 |
| commit | 7bddf2b0e4e9a57c561b4c1cab63de0d008a6846 (patch) | |
| tree | dbefbf2b246fef5703058b4b10f4cca7d8ad593e | |
| parent | 8215d517e4db95675998b281ba81ce5c49cc5e8f (diff) | |
| parent | ae09d3e1fefd0ef4d15365c23e7bcb82a904a25e (diff) | |
| download | perlweeklychallenge-club-7bddf2b0e4e9a57c561b4c1cab63de0d008a6846.tar.gz perlweeklychallenge-club-7bddf2b0e4e9a57c561b4c1cab63de0d008a6846.tar.bz2 perlweeklychallenge-club-7bddf2b0e4e9a57c561b4c1cab63de0d008a6846.zip | |
Merge pull request #1820 from choroba/ech-arl
Use @h{@a} = () instead of undef @h{@a}
| -rwxr-xr-x[-rw-r--r--] | challenge-009/e-choroba/perl5/ch-1.pl | 2 | ||||
| -rw-r--r-- | challenge-057/e-choroba/perl/Tree.pm | 2 | ||||
| -rwxr-xr-x | challenge-060/e-choroba/perl/ch-2.pl | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/challenge-009/e-choroba/perl5/ch-1.pl b/challenge-009/e-choroba/perl5/ch-1.pl index 4a74e71fe3..561873482a 100644..100755 --- a/challenge-009/e-choroba/perl5/ch-1.pl +++ b/challenge-009/e-choroba/perl5/ch-1.pl @@ -6,7 +6,7 @@ use feature qw{ say }; sub distinct_digits { my ($n) = @_; my %d; - undef @d{split //, $n}; + @d{split //, $n} = (); return keys %d } diff --git a/challenge-057/e-choroba/perl/Tree.pm b/challenge-057/e-choroba/perl/Tree.pm index a0a4a8a51f..176c5f574a 100644 --- a/challenge-057/e-choroba/perl/Tree.pm +++ b/challenge-057/e-choroba/perl/Tree.pm @@ -28,7 +28,7 @@ sub from_edges { push @children, $child; } my %root; - undef @root{ keys %tree }; + @root{ keys %tree } = (); delete @root{ @children }; my @roots = keys %root; die "One root not found: @roots." if @roots != 1; diff --git a/challenge-060/e-choroba/perl/ch-2.pl b/challenge-060/e-choroba/perl/ch-2.pl index 0894531600..438c4e5954 100755 --- a/challenge-060/e-choroba/perl/ch-2.pl +++ b/challenge-060/e-choroba/perl/ch-2.pl @@ -5,7 +5,7 @@ use strict; sub extend { my ($length, $short, $long) = @_; my %next; - undef @next{@$short}; + @next{@$short} = (); for my $i (0 .. $#$short) { for my $j (0 .. $#$short) { my $new = 0 + ($short->[$i] . $short->[$j]); @@ -25,7 +25,7 @@ sub extend { sub find { my ($length, $greater, @list) = @_; my @long = grep $length == length $_, @list; - my %long; undef @long{@long} if @long; + my %long; @long{@long} = (); return grep $greater > $_, extend($length, \@list, \%long); } |
