From 0501239761e54021f7397a227f63df4b18743819 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Thu, 7 Nov 2024 16:33:56 +0200 Subject: [PATCH] comments --- sites/en/pages/self-testing-with-modulino.txt | 24 +++++++++++++++++-- .../separating-test-data-from-test-code.txt | 2 +- .../serving-static-site-using-plack-psgi.txt | 7 +++++- ...imple-cgi-script-to-send-form-by-email.txt | 10 +++++++- ...estamp-generation-using-posix-strftime.txt | 14 ++++++++++- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/sites/en/pages/self-testing-with-modulino.txt b/sites/en/pages/self-testing-with-modulino.txt index 0bbe71909..4347830fb 100644 --- a/sites/en/pages/self-testing-with-modulino.txt +++ b/sites/en/pages/self-testing-with-modulino.txt @@ -5,7 +5,7 @@ =books testing =author szabgab =archive 1 -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -72,6 +72,26 @@ Despite this advantage of course the need to compile this extra code on every in

More about self testing Modulinos

-Read more about self testing Modulinos in +Read more about self testing Modulinos in Mastering Perl by brian d foy who coined the term. +

Comments

+ +Wow! It's a neat concept :) What really surprised me is the "import Test::More;". If I understand correctly, It's indirect method calling, right? + + +Some odd little corners of Perl. I hope this helps clear things up. + +It's just doing what `use` does at compile time at run time. That way you only get the Test::More overhead if you are actually using it. See https://perldoc.perl.org/functions/use + +Indirect method calls are when you use the `my_method MyClass arg1, arg2, ...` syntax. You don't see it much because we have learned to avoid it due to the fact that it is ambiguous. See https://perldoc.perl.org/perlobj#Indirect-Object-Syntax + +It's all in TFM, assuming you can find it. I've been rereading the darn things for nearly 20 years and sometimes things still surprise me. + + +
+ +the need to compile this extra code on every invocation + +Compromise might be to move tests to t/xxx.t once you have finished development. And add a "require" in the self_test sub. + diff --git a/sites/en/pages/separating-test-data-from-test-code.txt b/sites/en/pages/separating-test-data-from-test-code.txt index 721e25df0..3d298ccde 100644 --- a/sites/en/pages/separating-test-data-from-test-code.txt +++ b/sites/en/pages/separating-test-data-from-test-code.txt @@ -5,7 +5,7 @@ =status show =books testing =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start diff --git a/sites/en/pages/serving-static-site-using-plack-psgi.txt b/sites/en/pages/serving-static-site-using-plack-psgi.txt index 400909228..8264c8803 100644 --- a/sites/en/pages/serving-static-site-using-plack-psgi.txt +++ b/sites/en/pages/serving-static-site-using-plack-psgi.txt @@ -5,7 +5,7 @@ =books psgi =author szabgab =archive 1 -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -26,3 +26,8 @@ middleware that handles the files in the given directory. Check out the other articles on Plack/PSGI. + +

Comments

+ +There is handy oneliner as well: plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root => ".")->to_app' + diff --git a/sites/en/pages/simple-cgi-script-to-send-form-by-email.txt b/sites/en/pages/simple-cgi-script-to-send-form-by-email.txt index 570576431..bc8e85c95 100644 --- a/sites/en/pages/simple-cgi-script-to-send-form-by-email.txt +++ b/sites/en/pages/simple-cgi-script-to-send-form-by-email.txt @@ -4,7 +4,7 @@ =status show =books cgi =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -222,4 +222,12 @@ This can create an open m that can be used to send spam. +

Comments

+ +Thanks Gabor. You have no idea how many of your articles I have read to help me with my perl projects. Regards. + +
+ +Hi, I want to do something similar to your article. I want to display "Thanks for your submission" after submitting input by the user and simultaneously execute the cgi script. How can I do that? + diff --git a/sites/en/pages/simple-timestamp-generation-using-posix-strftime.txt b/sites/en/pages/simple-timestamp-generation-using-posix-strftime.txt index 3f4781131..96d8389ca 100644 --- a/sites/en/pages/simple-timestamp-generation-using-posix-strftime.txt +++ b/sites/en/pages/simple-timestamp-generation-using-posix-strftime.txt @@ -4,7 +4,7 @@ =status show =books beginner =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -187,3 +187,15 @@ say strftime '%B', @time; # November See also
strftime in Python that I used as the source of some of the explanations. +

Comments

+ +%z is useful. +0100 is often handy. + +
+ +It's POSIX -- the placeholder values are supplies by your operating system. I agree that the perldoc could be useful and echo these, but on at least FreeBSD, "man strftime" lists all the supported values for that platform. + +
+ +In Python's strftime, if you want a decimal hour (e.g. "2" instead of "02") you can use "%-I" instead of "%I" ... Is there any equivalent approach in this Perl strftime function? +