Back already with this week's solutions to the PWC #212. Spoiler alert, because the challenge doesn't close for another few days if you want to have a try.
Challenge #1 - Spinning Letters
This week we've got a simple letter rotation. Take each letter of the word provided and rotate it by each number in the list. At first I thought this would be a lot longer code. i even put it in a sub. That actually doubles the size though for absolutely no benefit, so I just simplified. We split the word, then loop through the letters and apply the rotation. If it wraps we start from the start of the alphabet. Upper-case is handled with a simple test to insert the right case of each character. Then we don't even bother putting the word back together again because we can just say it as-is.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on February 4, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Reverse Vowels
You are given a string, $s.
Write a script to reverse all the vowels (a, e, i, o, u) in the given string.
The other day I was working on yet another side project. Almost immediately I got side tracked. Does that make the new project a side side project?
What shiny bobble or cool new tech got my attention you ask? It wasn't $buzzword, or $fancy_tech. Nawe, nothing that resumé worthy. Instead, I decided to see what a MVP for a REST API would look like in using Catalyst. Look ma, no extra modules! Except a JSON one, but I don't count it since Catalyst also uses a JSON module.
NOTE: If you are trying to be productive, you probably want to just use Catalyst::Action::REST instead of rolling your own. That's what I've used at work with great success.
Other than generating the scripts I went ahead and hand wrote out everything else and was pleasantly surprised. There was so little code that I went ahead and retyped the only three modules needed here. Apologies if there's a typo.
Paul, Philippe, and Ricardo had our mostly-weekly Zoom call today.
We began by discussing last week, when Pete K from TPRF joined us and we talked about what TPRF could do to help p5p. (Main topics then, which didn’t get any firm action items, were support for critical infrastructure and services and bounties for implementation of PPCs.)
Most of our time this week was spent on the upcoming v5.38.0 release, especially what might be blocking it. (Notable: two new deprecation warnings added in the last two releases — smartmatch, and tick as package separator.)
We discussed strategies used by other languages to make things more attractive for developers, like batteries included. We didn’t end up with any plan of action from this.
In a few weeks, we’ll all be in one place, and look forward to looking carefully at the color of Chartreuse.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on February 4, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 1: Three Power
You are given a positive integer, $n.
Write a script to return true if the given integer is a power of three otherwise return false.
Perl has had the CPAN and awesome websites like MetaCPAN and its predecessor search.cpan.org for a long time, so unlike how things happen in other programming language ecosystems, many Perl projects have felt no need to start their own websites for documentation, package downloads, and community — all these things were already provided.
However, I do feel that this centralization keeps Perl content on the Internet very isolated and makes Perl less visible than other programming languages.
Hi ! Everyone, I am back here to ask environmental issue.
When I ran the following CGI.pm testing script before placing at /var/www/cgi-bin, but it is still at /home/mkido/bin. Perl script ran successfully at the Terminal, and replied back the OUTPUT below there.
Perl Script, check.pl
#!/usr/bin/env perl
use strict;
use warnings;
use CGI;
my $q = CGI->new;
print $q->header();
print "OK";
===================
OUTPUT
mkido@localhost$check.pl [Enter to run it.]
Content-Type: text/html; charset=ISO-8859-1
OK
mkido@localhost$
This output result evoked my recognition. Is this Rocky 9.1 Web Server running to provide charset=ISO-8859-1 ?? I want to set all replies from the Server to charset=UTF-8. The httpd.conf is already set to charset=UTF-8. Is there any other setting adjustment somewhere in environmental configuration on my server to change from charset=ISO-8859-1 to charset=UTF-8 ?? Thanks, thanks.
Today, the popular Dark Sky weather API is shutting down. I did a little write-up for non-Perl devs on DEV.to, but I thought I'd post here a couple of potentially useful modules I released to CPAN recently.
Weather::WeatherKit accesses the WeatherKit REST API, which is Apple's official Dark Sky replacement. The module uses Crypt::JWT to create tokens, so accessing WeatherKit then is as simple as:
use Weather::WeatherKit;
my $wk = Weather::WeatherKit->new(
team_id => $apple_team_id,
service_id => $weatherkit_service_id,
key_id => $key_id,
key => $private_key
);
my %report = $wk->get(
lat => 51.2,
lon => -1.8,
dataSets => 'currentWeather'
);
Of course, this API is sort of free, as it requires an Apple developer account. If you don't have one and don't want to get one, there are some alternative APIs, but for the purposes of this post I'll stick to 7Timer, via Weather::Astro7Timer. Even simpler, as it does not need authentication:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 28, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Weakest Row
You are given an m x n binary matrix i.e. only 0 and 1 where 1 always appear before 0.
A row i is weaker than a row j if one of the following is true:
a) The number of 1s in row i is less than the number of 1s in row j.
b) Both rows have the same number of 1 and i < j.
Write a script to return the order of rows from weakest to strongest.
Destination: Graph
Date of Latest Release: Feb 12, 2023
Distribution: Graph
Module version: 0.9726
Main Contributors: Jarkko Hietaniemi (JHI)
Current Maintainer: Neil Bowers (NEILB)
License: [perl_5]
Long time ago I claimed in front of a friend I would write a short introduction to graph theory, but I had been not able to figure out where I should start. Neither I would try today. The mathematical objects graphs, or the abstract data structures graphs, are full of interesting behaviors being studied in the discrete math subdiscipline graph theory. The CPAN module Graph is designed to empower Perl programmers doodle with undirected graphs and directed graphs (and also multigraphs and hypergraphs - not going to visit these functionalities here).
I'm back this week with PWC #210. Last week I was very busy and spent a long time reviewing other peoples' far more efficient solutions to #208, so I didn't get to doing any solutions for #209. The usual disclaimer about this could contain spoilers, so if you're trying to solve the challenge yourself you may want to skip this post for now. So let's get right into this.
Kill And Win
For this challenge I decided to use some of the tools I learned about in the solutions other people submitted for #208, especially the ways hashes can make the process more efficient. The goal is to find the number in the list where you can delete the most points by deleting the number and its adjacent numbers plus and minus one. You get to count each number however many times it appears in the list.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 21, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Unique Sum Zero
You are given an integer, $n.
Write a script to find an array containing $n unique integers such that they add up to zero.
Example 1
Input: $n = 5
Output: (-7, -1, 1, 3, 4)
Two other possible solutions could be as below:
(-5, -1, 1, 2, 3) and (-3, -1, 2, -2, 4).
Bug reporting by email: we commit to nothing as an organisation. Some would-be submitters of issues don’t want to use GitHub. They can just send an email to perl5-porters and hope that some helpful soul will copy-paste to GitHub. We encourage the conventional use of GitHub.
On the topic email bug reports, it’s likely time to deprecate perlbug as a way to send bug reports. It could be updated to point the user to GitHub, and to print perl -V output (etc.) to copy and paste. We should also have a better set of templates for issues on GitHub.
The segfaults on feature-class and refaliasing won’t be fixed before 5.38, and should just be documented as “known bugs”
After we discussed renaming RFC to PPC, the general sentiment seemed to be “in favor”, so we’re going to make the rename
Rik volunteered to release 5.38, we still need a release manager for 5.37.11
Some discussions about preparing the Perl Toolchain Summit plans (which will host the first ever in-person PSC meeting)
Date of Latest Release: Mar 09, 2012
Distribution: Text::Extract::Word
Module version: 0.02
Main Contributors: Stuart Watt (SNKWATT)
License: The Artistic License 2.0
Date of Latest Release: Jan 26, 2023
Distribution: MsOffice::Word::Surgeon
Module version: 2.01
Main Contributors: Laurent Dami (DAMI)
License: The Artistic License 2.0
First of all, a greeting. I posted an introduction with a notification of intent to take over a module on CPAN, but the maintainer responded to me. I'm Avery, I'm developing SeekMIDI, a small graphical MIDI sequencer. I started it in 2016 and I took a long break from programming entirely, and I've just restarted developing my programming skills again. For starters, I'm working on Perl Weekly Challenges and bug fixes to modules.
Without further ado, here are my solutions to the PWC #208. All solutions are about to be posted, but this could be a spoiler if you're trying to solve it too. I was very pleased this week that I got it down to about 15-25 minutes for each task, so I'm definitely getting more comfortable in Perl again.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 21, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 1: Special Numbers
You are given an array of integers, @ints.
Write a script to find the sum of the squares of all special elements of the given array.
An element $int[i] of @ints is called special if i divides n, i.e. n % i == 0, where n is the length of the given array. Also the array is 1-indexed for the task.
Until recently I runs all of my Perl scripts as well as Perl_CGI scripts by starting the folowing salutation,
#! /usr/bin/perl -w
The script with this beginning runs well at BASH shell at (/home/mkido/bin) LINUX such as Fedora, Ubuntu, Rocky (Alma-derivative). However, almost right now I noticed some of Perl example around has the different first line as below,
#! /usr/bin/env perl
And it doesn't seem to run at HOME BASH shell (/home/mkido/bin) by simple way of executing it by-itself by the command line. Will someone explain me about what is this [env perl] stuff? Thank you so much.
We had an abbreviated PSC call today, largely due to an unexpected delay.
We discussed offering split-up deprecation categories, so you can no warnings 'deprecated::.xyz' and re-affirmed that we want to do this.
We talked about improving the backcompat of strict-vs-version behavior for use vX where X is older than v5.36 and agreed we’d bring that back, but wanted to discuss more about other related changes to the use-vX code.