diff options
| author | robbie-hatley <Robbie.Hatley@gmail.com> | 2024-07-23 01:02:06 -0700 |
|---|---|---|
| committer | robbie-hatley <Robbie.Hatley@gmail.com> | 2024-07-23 01:02:06 -0700 |
| commit | 43cf8bdccb016d1ea8db803050cce243931a50fe (patch) | |
| tree | 6ee62a69f6052f57629fbf9d4de7f0929dc9b07a | |
| parent | 74702d0406abfc874d4044a9a8e0fac1915b585f (diff) | |
| download | perlweeklychallenge-club-43cf8bdccb016d1ea8db803050cce243931a50fe.tar.gz perlweeklychallenge-club-43cf8bdccb016d1ea8db803050cce243931a50fe.tar.bz2 perlweeklychallenge-club-43cf8bdccb016d1ea8db803050cce243931a50fe.zip | |
I modified script 1 to use :prototype(\@\@) to simplify invocation.
| -rwxr-xr-x | challenge-279/robbie-hatley/perl/ch-1.pl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/challenge-279/robbie-hatley/perl/ch-1.pl b/challenge-279/robbie-hatley/perl/ch-1.pl index cbdc28e882..8bfb44be55 100755 --- a/challenge-279/robbie-hatley/perl/ch-1.pl +++ b/challenge-279/robbie-hatley/perl/ch-1.pl @@ -50,7 +50,7 @@ Output is to STDOUT and will be each input followed by the corresponding output. use v5.36; use List::MoreUtils 'zip6'; - sub sort_letters ($letters, $weights) { + sub sort_letters :prototype(\@\@) ($letters, $weights) { join '', map {$$_[0]} sort {$$a[1]<=>$$b[1]} @@ -87,11 +87,11 @@ my @arrays = @ARGV ? eval($ARGV[0]) : # MAIN BODY OF PROGRAM: $"=', '; for my $aref (@arrays) { - my $letters = $$aref[0]; - my $weights = $$aref[1]; - my $word = sort_letters($letters,$weights); + my @letters = @{$$aref[0]}; + my @weights = @{$$aref[1]}; + my $word = sort_letters(@letters,@weights); say ''; - say "letters = (@$letters)"; - say "weights = (@$weights)"; + say "letters = (@letters)"; + say "weights = (@weights)"; say "Sorted letters = $word"; } |
