aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Muth <matthias.muth@gmx.de>2025-05-25 23:37:14 +0200
committerMatthias Muth <matthias.muth@gmx.de>2025-05-25 23:37:14 +0200
commit7562c5eb08efda0c0ada2e1b836a717d26cc727e (patch)
tree5a1c858c1f1f31282c0bba4479f6a84aa341205c
parent4fbbfd10e38d481656b9c7fde401635797af13b5 (diff)
downloadperlweeklychallenge-club-7562c5eb08efda0c0ada2e1b836a717d26cc727e.tar.gz
perlweeklychallenge-club-7562c5eb08efda0c0ada2e1b836a717d26cc727e.tar.bz2
perlweeklychallenge-club-7562c5eb08efda0c0ada2e1b836a717d26cc727e.zip
Challenge 322 Task 1 and 2 solutions in Perl by Matthias Muth - Update
-rwxr-xr-xchallenge-322/matthias-muth/perl/ch-1.pl36
1 files changed, 15 insertions, 21 deletions
diff --git a/challenge-322/matthias-muth/perl/ch-1.pl b/challenge-322/matthias-muth/perl/ch-1.pl
index 638df17d8c..bdc07c9c43 100755
--- a/challenge-322/matthias-muth/perl/ch-1.pl
+++ b/challenge-322/matthias-muth/perl/ch-1.pl
@@ -10,9 +10,6 @@
use v5.36;
-use Dsay;
-$debug{ALL} = 1;
-
sub string_format_re_d_btof( $str, $i ) {
$str =~ s/-//g;
my @chunks;
@@ -134,16 +131,15 @@ sub string_format_nd_nomy_tail_push_rev_inline_w_nopush( $str, $i ) {
return join "-", reverse @chunks, substr( $str, 0, $index );
}
-# *string_format = \&string_format_re_nd_rev_ftob;
-
-=for testing
-
-use Test2::V0 qw( -no_srand );
+*string_format = \&string_format_nd_nomy_tail_push_rev_inline_w_nopush;
#
# Flexible testing.
#
+use Test2::V0 qw( -no_srand );
+use Data::Dump qw( pp );
+
my $sub_name = "string_format";
my @tests = (
[ "Example 1:", [ "ABC-D-E-F", 3 ], [ "ABC-DEF" ] ],
@@ -168,7 +164,7 @@ for my $sub ( sort grep /^${sub_name}/, keys %:: ) {
done_testing;
-=cut
+__END__
use Benchmark qw( :all :hireswallclock );
@@ -176,6 +172,16 @@ use Benchmark qw( :all :hireswallclock );
my $str = join "", 1..102;
cmpthese( -5, {
+ re_d_btof =>
+ sub { string_format_re_d_btof( $str, 4 ) },
+ re_nd_rev_ftob =>
+ sub { string_format_re_nd_rev_ftob( $str, 4 ) },
+
+ d_btof_unshift =>
+ sub { string_format_d_btof_unshift( $str, 4 ) },
+ d_btof_push_rev =>
+ sub { string_format_d_btof_push_rev( $str, 4 ) },
+
nd_ftob =>
sub { string_format_nd_ftob( $str, 4 ) },
nd_btof_push_rev =>
@@ -193,15 +199,3 @@ cmpthese( -5, {
nd_nomy_tail_push_rev_inline_w_nopush =>
sub { string_format_nd_nomy_tail_push_rev_inline_w_nopush( $str, 4 ) },
} );
-
-__END__
- re_d_btof =>
- sub { string_format_re_d_btof( $str, 4 ) },
- re_nd_rev_ftob =>
- sub { string_format_re_nd_rev_ftob( $str, 4 ) },
-
- d_btof_unshift =>
- sub { string_format_d_btof_unshift( $str, 4 ) },
- d_btof_push_rev =>
- sub { string_format_d_btof_push_rev( $str, 4 ) },
-