Perl Weekly Challenge # 24: Smallest Script and Inverted Index

These are some answers to the Week 24 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in several days from now (September 8 , 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.

Challenge # 1: Smallest Script With No Execution Error

Create a smallest script in terms of size that on execution doesn’t throw any error. The script doesn’t have to do anything special. You could even come up with the smallest one-liner.

I was first puzzled by this strange specification. Can it be that we really want a script that does nothing? Does it have to be the shortest possible script.

Well, after reading again, yes, it seems so.

I'll go for one-liners.

My script in Perl 5:

$ perl -e ''

Perl Weekly Challenge W023 - Difference, Factors and Poem

This week's challenge is composed of three tasks.The first one is to get the n-th order of forward difference of a given list.

Task #1 - N-th order difference:
Suppose we have list (X) of numbers: 5, 9, 2, 8, 1, 6 and we would like to create 1st order forward difference series (Y). So using the formula Y(i) = X(i+1) - X(i), we get the following numbers: (9-5), (2-9), (8-2), (1-8), (6-1). In short, the final series would be: 4, -7, 6, -7, 5. If you noticed, it has one less number than the original series. Similary you can carry on 2nd order forward difference series like: (-7-4), (6+7), (-7-6), (5+7) => -11, 13, -13, 12.
Solution:

Perl Weekly Challenge 023: Forward difference series & Prime decomposition

Forward difference series

Create a script that prints nth order forward difference series. You should be a able to pass the list of numbers and order number as command line parameters.
Series592816
Order
1(9-5)(2-9)(8-2)(1-8)(6-1)
4-76-75
2(-7-4)(6+7)(-7-6)(5+7)
-1113-1312
3(13+11)(-13-13)(12+13)
24-2625
4(-26-24)(25+26)
-5051
5(51+50)
101

Perl Newbies weekly update 2019/8/31 - uc, lc, ucfirst, lcfirst functions

Hear Good News!

I report Perl Newbies weekly update.

I add uc, lc, ucfirst, lcfirst functions.

Perl Newbies

I start to work writing perl document for Perl 5 Newbies.

I think Perl Community(Mainly USA and more Mainly Silicon Valley) isn't intereted in Yung Perl People who want to know Perl programing language.

There are no easy, understandable, modern entries and perl programing examples in blogs.perl.org.

I try to continue to write entries for Perl 5 Newbies.

The MongoDB Perl Driver is being deprecated

From Twitter

We've made this decision using hard data; over the past few years we have surveyed our user base and talked to companies that use the Perl driver. They've told us how they aren't developing new applications using Perl and have moved these applications into maintenance mode. This has meant that they have few demands for new MongoDB feature to be supported in the Perl driver.

We also looked at support requests and questions in the community, and found no questions about the Perl driver had been asked since 2018 on the mongodb-user list.

...

Perl Weekly Challenge # 23: Difference Series and Prime Factorization

These are some answers to the Week 23 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in several days from now (September 1, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.

Challenge # 1: nth Order Difference Series

Create a script that prints nth order forward difference series. You should be a able to pass the list of numbers and order number as command line parameters. Let me show you with an example.

Splitting on a change in Perl6

I had more thoughts about splitting on character changes, partly thanks to a mailing list thread, which led to more questions.

As a prelude, here are regexps that splits when changing to the letter B

# If the cursor is before B, and is after a character, and is not after B, split
> say "ABBBCDEEF".split(/<?before (B) {} ><?after . ><!after B >/).perl
("A", "BBBCDEEF").Seq
# If the cursor is before B, and is after character-class-exlcuding B, split
> say "ABBBCDEEF".split(/<?before (B) {} ><?after <-[B]> >/).perl
("A", "BBBCDEEF").Seq
And when changing from the letter B
# If the cursor is after B, and is before a character, and is not before B, split
say "ABBBCDEEF".split(/<?after (B) {} ><?before . ><!before B >/).perl
("ABBB", "CDEEF").Seq

Perl Weekly Challenge - 6 months

Last time we presented you the success story of 3 months. It is now time to share 6 months story with you. I would like to take this opportunity to thank each and every contributors. I would also like to take a look what have we achieved in these 6 months.Here is the list of achievements

#1 Active bloggers

I would call this one of the biggest achievements that we have had 228 blogs in the last 6 months. On top this, we have had 11 blogs , as listed below, by Damian Conway . Some of the bloggers started blogging again after long break and some were first timers. You can find all the blogs in the weekly Recaps and Reviews .

Recaps

I create new site "Perl Newbie"

I create new site "Perl Newbie"

Perl Newbie

Perl Newbie is the site for people to leran Perl programing. Perl is good at text processing,Linux server administration, and Web development. You can use Perl on most operation systems. Perl backword compatiblity is very high. Perl Newbie chears people who try to learn Perl and use Perl for your development. Let't talk about Perl. "He uses Perl and has much fun."

This is created by Giblog.

Perl Weekly Challenge W022 - Sexy Primes

I was googling about perl, hoping to see an active community that is dedicated to perl. I have been an active member of codesignal and I primarily use perl to solve the challenges. And then, I came across the website perlweeklychallenge.org that is being maintained by Mohammad Anwar. The website as the name implies, post challenges every week it usually consist of three tasks.

Task #1 - Sexy Prime For this week, the first task is to print the first 10 sexy primes
Write a script to print first 10 Sexy Prime Pairs. Sexy primes are prime numbers that differ from each other by 6. For example, the numbers 5 and 11 are both sexy primes, because 11 - 5 = 6. The term “sexy prime” is a pun stemming from the Latin word for six: sex. For more information, please checkout wiki page.
Solution #1
Below is my perl5 solution for the task:
Note: The code was intentionally obfuscated for fun (The syntax highlighter fails in $' )

Splitting on a change, Challenge 20 Task 1

I like reading the Perl Weekly Challenge even if I rarely participate.

It struck me that task 1 of Week 20 asked "to accept a string from command line and split it on change of character" - but every solution that I read in the recap looked for runs of the same character instead of the literal interpretation of the challenge.

Then I found, it was a dead end for me...

$ perl -E 'say join " ",split /(.)(?!\1)/,scalar '
ABBCDEEF
 A B B  C  D E E  F

Ah, I want zero-width on each side, but I want to both use capture for \1 but NOT also have "split" keep the capture, can't have it both ways...

$ perl -E 'say join " ",split /(?<=(.))(?!\1)/,scalar '
ABBCDEEF
A A BB B C C D D EE E F F

Perl6's expressiveness won for me, but I think this could be cleaner, and it has a spurious empty string at the beginning. Ideas for improvement, dear reader?

say "ABBCDEEF".split(/<?before (.) {} :my $c=$0;><!after $c> /).perl
("", "A", "BB", "C", "D", "EE", "F").Seq

Perl Weekly Challenge # 22: Sexy Prime Pairs and Compression Algorithm

These are some answers to the Week 22 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in several days from now (August 25, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.

Challenge # 1: Sexy Prime Pairs

Write a script to print first 10 Sexy Prime Pairs. Sexy primes are prime numbers that differ from each other by 6. For example, the numbers 5 and 11 are both sexy primes, because 11 - 5 = 6. The term “sexy prime” is a pun stemming from the Latin word for six: sex. For more information, please checkout wiki page.

Swiss Perl Workshop - Post Event & Future

The Swiss Perl Workshop is over for another year. Thanks to all who attended, sponsored, helped out on the day and before, gave talks, and made suggestions. There are a few photos of the event available on the Perl Events Instagram feed.

The videos of the talks are available here. The recordings were largely successful, although one video still needs some putting together due to technical issues - this one will appear later.

Open Discussion

On the second day of the workshop an open discussion took place. This was a continuation of a discussion started back in May, in Bern, and covered several issues about the current state and future of the workshop.

I made a few notes to cover it for those who were not present, as we did not record this discussion due to its impromptu nature. I have split the topics into sections below. Note that the use of "Perl" below should be taken to mean both Perl 5 and Perl 6.

Future Name

With friends like these...

C-o-rr-a-ll-i-n-g d-i-tt-o-e-d l-e-tt-e-r-s

I was going to focus this week on the first task of the 20th Perl Weekly Challenge...but what can I say? The task was a break a string specified on the command-line into runs of identical characters:

    "toolless"        →   t  oo  ll  e  ss
    "subbookkeeper"   →   s  u  bb  oo  kk  ee  p  e  r
    "committee"       →   c  o  mm  i  tt  ee

But that’s utterly trivial in Perl 6:

    use v6.d;

    sub MAIN (\str) {
        .say for str.comb: /(.) $0*/
    }

And almost as easy in Perl 5:

Day Two at the SPW, or is it SPAFW or WSRAK 2019

A rather relaxed day here at the SPW 2019. We started out with a rather animated open discussion of the future on small Perl meet-ups. Seems it is not only the SWP that can have troubble attracting speakers or attendee, people from around the EU Perl community also voiced some concern that organizing small local workshops is getting more difficult.

On suggestion was changed the name or the SPW to something less perlish (which makes sense as Perl6 will soon have its own name). Another suggestion was joining up with more regional PM groups in the Alpine area to attract a few more attendees and organizers. Personally I have seen the same problems come up in other user groups, not a sign of decline but more a sign that the days of the small workshop may be numbered.

Perl Weekly Challenge # 21: Euler's Number and URL Normalizing

These are some answers to the Week 21 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in several days from now (August 18, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.

Challenge # 1: Euler's Number

Write a script to calculate the value of e, also known as Euler’s number and Napier’s constant. Please checkout this wiki page for more information.

The number e is a mathematical constant that is the base of natural logarithms: It is the unique number whose natural logarithm is equal to 1 and its value is approximately 2.71828.

Euler's Number in Perl 6

Perl 6 has a built-in constant, e, for Euler's number, which we can just print:

$ perl6 -e 'say e'
2.718281828459045

CPAN Game: 100+ days of daily CPAN upload

Yes, I am back again with another blog. I just need a reason to write about. This time, I am going to talk about one of the most fun game I am involved with for long time. In short, this game requires you to upload one distribution to CPAN every day. It sounds simple but it is far from simple.

Current Chains

All-time Chains

Screenshots taken from Neil Bowers personal website.

If you don't know the history of the game, let me give you little introduction, I was first introduced to the game by one of the blog by Neil Bowers. I got addicted to it from day one. Few months later, Barbie blogged once he completed one year of CPAN uploads. It worked like a catalyst to my already addiction.

Solving two problems

A Regular Question

This weeks perl weekly challenge had a pretty straightforward question: take a string and split it when the characters change. That's a fairly straightforward regex issue:

perl -pE's/(.) \g1*/$& /gx'

Here we match any character (.) once. We capture this in a group. Then, we use backreferencing to match as many more copies of that group as we can. We use the s operator to then replace what we found with itself ($& is the entire match that was found) followed by a space.

Conveniently, the challenge didn't specify what 'splitting' entails, so this is technically all we need to do. However, it gives us an extra empty space at the end of the match. In order to get rid of that (the proverbial second problem introduced by regexes), we have two approaches.

The RegEx Rabbit Hole

We could tell the regex not to match if it gets to the end of the string. We would do that with a zero width negative lookahead:

Day One at SWP 2019 Olten

Day one here at the SPW coming home again the Florian in Olten CH.
We started the day with Liz Mattijen debunking myths found on the inter-web about Perl 6, Raku, Cammila ah what-ever they are calling it these days.

Liz was very passionate about Perl6 and it was a little sad to hear her story the state of Perl 5 and Perl 6 but we can always hope.

I was up next and was a little flustered to go up next to one of the legends but I think my talk on the history of routes and my personal style of writing route when ok, at least the crowd laughed at the parts I though where funny.

Perl Weekly Challenge 020: Split on change + amicable numbers

I spent this week in Rīga at the Perl Conference. I had two talks there, a standard 20-minutes one and a lightning talk (5 minutes). I dedicated all my free time to the preparation of the slides, but fortunately the assignments were rather easy this week, so I submitted the solutions on Monday already before leaving for Rīga.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.