From 43cf8bdccb016d1ea8db803050cce243931a50fe Mon Sep 17 00:00:00 2001 From: robbie-hatley Date: Tue, 23 Jul 2024 01:02:06 -0700 Subject: I modified script 1 to use :prototype(\@\@) to simplify invocation. --- challenge-279/robbie-hatley/perl/ch-1.pl | 12 ++++++------ 1 file 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"; } -- cgit