<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: oldtechaa</title>
    <description>The latest articles on DEV Community by oldtechaa (@oldtechaa).</description>
    <link>https://dev.to/oldtechaa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1040756%2F0d12112b-7615-473d-aca1-3bb23e4d4d3d.png</url>
      <title>DEV Community: oldtechaa</title>
      <link>https://dev.to/oldtechaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oldtechaa"/>
    <language>en</language>
    <item>
      <title>Using Codeium in VS Code</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Sun, 21 Jan 2024 04:08:57 +0000</pubDate>
      <link>https://dev.to/oldtechaa/using-codeium-in-vs-code-6fe</link>
      <guid>https://dev.to/oldtechaa/using-codeium-in-vs-code-6fe</guid>
      <description>&lt;p&gt;Hi everybody, I've been a happy user of &lt;a href="https://marketplace.visualstudio.com/items?itemName=Codeium.codeium"&gt;Codeium&lt;/a&gt; for a little while (I am definitely not affiliated with the developers of Codeium and I have no vested interest in promoting it, I just like it) and wanted to share why I like it.&lt;/p&gt;

&lt;p&gt;Codeium is a free AI code assistant. You could think of it like Github Copilot, but free. I know what you might think, "if it's free you are the product", but in this case it's actually freemium. For enterprise usage there are costs, which seem definitely worth it for an enterprise, but for individuals it's free to use. They don't train on your data, either.&lt;/p&gt;

&lt;p&gt;I like it primarily because its completions are amazing! It can often write much of a function while you're still coming up with the concept, and even better, the code is quite high-quality, with the caveat that you should &lt;em&gt;&lt;em&gt;NEVER&lt;/em&gt;&lt;/em&gt; trust an AI tool to verify the accuracy or security of code. It's not always the fastest at producing a suggestion, but it's still faster than a human typing.&lt;/p&gt;

&lt;p&gt;Codeium's function explanations are not very helpful in my opinion. They're too fine-grained and essentially just tell you what the function is doing step-by-step, which is exactly what I could read the code to figure out. What I'd prefer to have explanations do is provide a broader explanation or summary of the purposes of a function and maybe why it does something in a certain way if it's an unfamiliar coding paradigm.&lt;/p&gt;

&lt;p&gt;Have you tried Codeium? A lot of people are anti-AI in development, a lot of people are essentially just using AI to write everything. I feel the latter is absolutely wrong and AI just isn't that trustworthy on accuracy/security. The former is probably fine, it just could be leaving efficiency on the table. Definitely don't use AI for everything, but if you want to, figure out how it can assist you. Let me know your thoughts on Codeium.&lt;/p&gt;

</description>
      <category>codeium</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Why I Moved From Perl to Python, or Why I Learned to Stop With the Camel and Love the Snake</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Thu, 18 Jan 2024 02:59:57 +0000</pubDate>
      <link>https://dev.to/oldtechaa/why-i-moved-from-perl-to-python-or-why-i-learned-to-stop-with-the-camel-and-love-the-snake-1jpi</link>
      <guid>https://dev.to/oldtechaa/why-i-moved-from-perl-to-python-or-why-i-learned-to-stop-with-the-camel-and-love-the-snake-1jpi</guid>
      <description>&lt;p&gt;Hi everybody,&lt;/p&gt;

&lt;p&gt;For those of you who have a history with my Perl Weekly Challenge solutions and who know me as one of the #perl tag moderators, I'm here to explain today why I haven't posted anything about Perl at all recently. I have entirely left the Perl ecosystem. Don't get me wrong, I don't hate it, my work has just taken me to the Python world and now there's no turning back for me.&lt;/p&gt;

&lt;p&gt;I have long been a supporter of Perl. I started my first true personal programming project in Perl in the mid-2010s, which I then got distracted from for quite some time with other activities. When major changes happened in my life, I started working with Perl again to refresh my skills for possible employment in software development.&lt;/p&gt;

&lt;p&gt;I know what people say about Perl, that it's dead and gone, that it's line noise, etc. But I still supported it. It was my favorite, my OG, you could say, so I stuck with it. It's not a terrible language, in my opinion.&lt;/p&gt;

&lt;p&gt;Why did I move off of Perl then? For my new job working on a Django project I actually gave Python a chance. I was reading the Python docs and everything just seemed incredibly powerful. Like what? Some of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The ease of list comprehensions. I know I could use map() or similar looping structures, but they're nowhere near as clear as Python list comprehensions.&lt;/li&gt;
&lt;li&gt;True OOP. No more figuring out whether I want Moose, Moo, Mouse, wait for Corinna (which looks impressive but a decade too late), bless(), or "Ah, whatever, I guess I'll just do procedural programming, then I don't have to add a dependency."&lt;/li&gt;
&lt;li&gt;A real, useful, standard library. I don't want to always have to decide whether I want to use this XML library or that XML library, this JSON library or that JSON library, etc. Sometimes I just want to have a default choice, with more powerful options available if I need them.&lt;/li&gt;
&lt;li&gt;Maintained libraries. With Perl, do I use the arguably better-designed library that hasn't seen a single update in 5 years and has an individual inactive author, or the worse library that hasn't seen a single update in 3 years and also has an individual inactive author? (Estimates, please don't quote me or ask for specific examples.) The community just is too far declined to maintain the existing codebase effectively.&lt;/li&gt;
&lt;li&gt;Syntax. Python's syntax is clear, English-like, and follows rules. Perl's is full of punctuation, often strung together in a way that is only readable to an experienced Perl programmer.&lt;/li&gt;
&lt;li&gt;Lack of backwards compatibility. You might say that's a feature. I say it's a liability. Code that sits without maintenance is a bad thing. There is no such thing as static code in a good environment. If your code has to be static, then company requirements need to change or you simply can stick with an old version of your language. Frequent breaking changes are annoying. Occasional breaking changes are very very healthy. Holding an entire language's development back by insisting on backwards compatibility at the expense of everything else is what has made Perl unable to keep up with other languages. It's not healthy for a language.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are my personal feelings and reasons for leaving Perl for Python. It was fun, and I wish the Perl community the best, but in my view, there's just nothing that Perl can do better than Python. (Except maybe for module imports. Have I mentioned how annoying Python imports are? No? They're annoying!)&lt;/p&gt;

&lt;p&gt;If I had any suggestions, the biggest one would probably be to break things. If people want their 5.8 code to run, they can run 5.8. Stop catering for them and advance the language. Also I would recommend expanding the standard library with well-tested, modern libs. These are effectively the biggest issues that need addressing with Perl.&lt;/p&gt;

&lt;p&gt;Have you switched from Perl to Python? Why have you switched? If you've considered it and stuck with Perl, why? If you're a staunch Perl supporter, why do you like it? Let us know in the comments below. Please keep it civil though.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;P.S. Why did I tag this with PHP? I meant to say something about my role now including some PHP, which I believe many feel is worse than Perl (I do). My goal is to rewrite that project eventually, because I don't want to be stuck on another declining language.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>perl</category>
      <category>python</category>
      <category>django</category>
      <category>php</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #237 - Carpe Diem</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Fri, 06 Oct 2023 11:57:06 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-237-carpe-diem-1i09</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-237-carpe-diem-1i09</guid>
      <description>&lt;p&gt;Hello everybody! Welcome back to the Weekly Challenge series, where today we're working on dates again. I like these challenges in particular, for some reason. In this case, we have a rather simple challenge except that it gives us less common date formats than usual.&lt;/p&gt;

&lt;p&gt;The challenge gives us a year, month, week(day) of the month, and day of week. Now DateTime provides us with get operations to find WoM and DoW info, but it doesn't provide set operations. For that we need to do a little math. Here's the code below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;
use DateTime;

my ($year, $month, $wom, $dow) = @ARGV;
my $obj = DateTime-&amp;gt;new(year =&amp;gt; $year, month =&amp;gt; $month, day =&amp;gt; 1);
if($obj-&amp;gt;dow() &amp;lt;= $dow) {
    $obj-&amp;gt;add(days =&amp;gt; (($dow - $obj-&amp;gt;dow()) + (($wom - 1) * 7)));
} else {
    $obj-&amp;gt;add(days =&amp;gt; ((7 - ($obj-&amp;gt;dow() - $dow)) + (($wom - 1) * 7)));
}
say 0 and exit if $obj-&amp;gt;month() != $month;
say $obj-&amp;gt;day();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We only really have to handle wrapping and assessing whether that day is possible within the month. We use DateTime because it just makes sense, and we create an object with the first day of the month that we're using. If the day is the same or earlier in the week (to save code complexity) than the day we're looking for, we shift the difference and add that to the number of weeks later that the target day is on. If the 1st of the month is later in the week than our target day, we wrap and still shift $wom-1 weeks later.&lt;/p&gt;

&lt;p&gt;If our addition to the date means we're now in a different month from the intended one we print out 0 and exit, otherwise we say what the date is now.&lt;/p&gt;

&lt;p&gt;It's that simple! Just 12 lines including file header and boilerplate. Hope to see you next week!&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
      <category>datetime</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #236 - Lemonade Stand</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Sat, 30 Sep 2023 10:43:04 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-236-lemonade-stand-50p5</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-236-lemonade-stand-50p5</guid>
      <description>&lt;p&gt;Welcome back to another round of the weekly challenge, with just one solution this week. I'm setting up a lemonade stand and need to deal with change. Interestingly, I can only sell one juice per person, so I hope you're not super thirsty!&lt;/p&gt;

&lt;p&gt;We can take $5, $10, and $20 bills, and we don't start with any change, so we need our previous customers to provide us with change for future customers. Let's find out if we can make change for a set of customers.&lt;/p&gt;

&lt;p&gt;Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;
use List::Util 'any';

my %till;
my $failure;
foreach my $bill (@ARGV) {
    if(!any {$bill == $_} (5, 10, 20)) {
        say('At least one bill provided is not $5, $10, or $20.') and exit;
    }
    $till{$bill}++;
    if($bill == 20) {
        if($till{10} and $till{5}) {
            $till{10}--;
            $till{5}--;
        } elsif($till{5} &amp;gt;= 3) {
            $till{5} -= 3;
        } else {
            $failure = 'false';
            last;
        }
    } elsif($bill == 10) {
        if($till{5}) {
            $till{5}--;
        } else {
            $failure = 'false';
            last;
        }
    }
}
say(defined($failure) ? $failure : 'true');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It might be possible to make this cleaner, but this is what I came up with quickly, so here it is. Our cash drawer is represented by the hash &lt;code&gt;%till&lt;/code&gt;, which contains our $5s, $10s, and $20s. We add each bill we get, then we need to make change (unless it's a 5). If we can't make change at any point, we set our failure flag and stop serving customers. We check for the ability to successfully make change depending on the bill we've been handed. For a 20, first we try to make change with a $10 and a $5, otherwise three $5s, and for a $10 we see if we have any $5s. That's all we have to do! It's a lot of code for a simple result.&lt;/p&gt;

&lt;p&gt;Hope to see you all next week. Enjoy!&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #235 - Splicing and Dicing</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Sat, 23 Sep 2023 00:16:03 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-235-splicing-and-dicing-42lj</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-235-splicing-and-dicing-42lj</guid>
      <description>&lt;p&gt;Hi everybody, we've got another two challenges this week, so let's dive into them!&lt;/p&gt;

&lt;h4&gt;
  
  
  Remove One
&lt;/h4&gt;

&lt;p&gt;The goal is to see if there's any one number that can be removed to make the set sorted in increasing order. Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;

my $success = 0;
REMOVAL: for my $removal (0 .. $#ARGV) {
    my @modified = @ARGV;
    splice(@modified, $removal, 1);
    for my $scan (1 .. $#modified) {
        if($modified[$scan] &amp;lt;= $modified[$scan - 1]) {
            next REMOVAL;
        }
    }
    $success = 1;
    last;
}

say ($success ? 'true' : 'false');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have a labelled outer loop for the numbers we choose to remove. $removal is set to the index of each number we attempt to remove, then we copy the array, remove that number, and scan the result to make sure they all are increasing. If they don't, we skip this number and move on.&lt;/p&gt;

&lt;p&gt;If we succeed, we set our flag and exit the loops and print the result.&lt;/p&gt;

&lt;h4&gt;
  
  
  Duplicate Ones
&lt;/h4&gt;

&lt;p&gt;The next one is an array shifting challenge. We want to insert a duplicate of each 0, shifting everything to the right, and popping off the list to keep the length the same.&lt;/p&gt;

&lt;p&gt;Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;

my @ints = @ARGV;
for(my $i = 0; $i &amp;lt;= $#ints; $i++) {
    if($ints[$i] == 0) {
        splice(@ints, $i, 0, 0);
        pop(@ints);
        $i++;
    }
}

say('(', join(', ', @ints), ')');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This one's also really quite simple. We scan the array, use splice to insert a 0, pop the last number off the end of the array, and skip over the 0 we just inserted. It's that simple!&lt;/p&gt;

&lt;p&gt;Both of this week's solutions make use of splice() to insert and remove array elements, something I haven't used a lot before.&lt;/p&gt;

&lt;p&gt;Stay tuned for next week's challenge, which should come out Monday!&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #234 - Sharing is Caring</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Thu, 14 Sep 2023 04:50:44 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-234-sharing-is-caring-98k</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-234-sharing-is-caring-98k</guid>
      <description>&lt;p&gt;Hi everybody! Back this week with a (surprisingly long) solution to just Task 1 of the weekly challenge. Task 2 makes no sense to me at all because it seems like examples 1 and 3 disagree with each other. Just sticking to one challenge for that reason. Anyways, let's dive into it!&lt;/p&gt;

&lt;p&gt;The goal here is to find the letters that all the provided words share. Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;

my @words;
my %result_chars;

for(@ARGV) {
    push(@words, [split(//, $_)])
}
@words = sort {$#{$a} &amp;lt;=&amp;gt; $#{$b}} @words;
$result_chars{$_}++ for @{$words[0]};

for my $word (1..$#words) {
    for my $key (keys(%result_chars)) {
        my $occurrences = grep(/$key/, @{$words[$word]});
        if($occurrences == 0) {
            delete($result_chars{$key});
            next;
        } elsif($occurrences &amp;lt;= $result_chars{$key}) {
            $result_chars{$key} = $occurrences;
        }
    }
}

for my $char (@{$words[0]}) {
    if($result_chars{$char}) {
        $result_chars{$char}--;
        say $char;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;First we make a 2D array of the characters in all the words. That way we only have to split the words up once, instead of repeatedly as we seek through them. It does mean a bit more complexity to deal with a matrix, unfortunately.&lt;/p&gt;

&lt;p&gt;We also sort the words by length so the shortest one is first, then make a histogram of all the letters in it. Now it's important to keep all the letters and not remove duplicates, because we have to print duplicates as we see from the example that prints "e, l, l".&lt;/p&gt;

&lt;p&gt;We loop through each word, then loop through each letter in the first word (keys of the histogram) and search the current word for that letter. If we don't find it, we delete the letter from the histogram. If we find fewer occurrences than in the histogram, we remove some from the histogram to show how many we actually can make in the current word. If that letter is in the histogram fewer or equal times to the occurrences in the word, we move on to the next letter.&lt;/p&gt;

&lt;p&gt;Next, for printing, we would have to have multiple loops to loop through the histogram and remove one instance at a time, so instead I decided I should simply search the original word for characters that successfully passed the test of the other words, then print those characters.&lt;/p&gt;

&lt;p&gt;When I first started, I thought this would be super easy, but I discovered complications numerous times through the challenge. Perhaps others will have some better ideas of solutions I can learn from. Unfortunately Flavio Poletti hasn't been doing his solutions recently, I always enjoyed them very much, but be sure to check out past solutions of his at &lt;a href="https://github.polettix.it/ETOOBUSY/"&gt;github.polettix.it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hopefully I'll be back next week with more solutions!&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #233 - Similar Words and Frequency Sort</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Wed, 06 Sep 2023 09:43:27 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-233-similar-words-and-frequency-sort-1bii</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-233-similar-words-and-frequency-sort-1bii</guid>
      <description>&lt;p&gt;Hello everybody! For this week's weekly challenge I thought the challenges looked really easy, but they both had a couple slight complicating factors. Also, this was the first time I've used sub signatures.&lt;/p&gt;

&lt;h4&gt;
  
  
  Similar Words
&lt;/h4&gt;

&lt;p&gt;For this one, we're looking for words that share all characters. We print out each pair of words.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;

my @words = @ARGV;
my $matched = 0;
for (my $i = 0; $i &amp;lt;= $#ARGV - 1; $i++) {
    my $start_word = $words[$i];
    my %start_chars = map {$_ =&amp;gt; 1} split(//, $start_word);

    for (my $j = $i + 1; $j &amp;lt;= $#ARGV; $j++) {
        my $match_word = $words[$j];
        my %match_chars = map {$_ =&amp;gt; 1} split(//, $match_word);

        if (hashes_equal(\%start_chars, \%match_chars)) {
            say $start_word . ", " . $match_word;
            $matched = 1;
        }
    }
}
say 0 unless $matched;

sub hashes_equal ($start_ref, $match_ref) {
    my %start_chars = %{$start_ref};
    my %match_chars = %{$match_ref};

    if (scalar keys %start_chars == scalar keys %match_chars) {
        foreach (keys %start_chars) {
            if (!defined($match_chars{$_})) {
                return;
            }
        }
        return 1;
    } else {
        return;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It essentially boils down to looping through all combinations of words in two loops, converting each word to a hash containing all unique characters. hashes_equal makes sure that the hashes have the same number of keys, then tries the keys and makes sure they have the same values.&lt;/p&gt;

&lt;h4&gt;
  
  
  Frequency Sort
&lt;/h4&gt;

&lt;p&gt;For this one, we're sorting numbers by how frequently they occur, in increasing order, except when they share a frequency, then we sort them decreasing by value.&lt;/p&gt;

&lt;p&gt;Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/perl
use v5.36;

my %ints;
$ints{$_}++ foreach @ARGV;

my %ints_by_occurrence;
my @results;

foreach (keys %ints) {
    push @{$ints_by_occurrence{$ints{$_}}}, $_;
}
foreach (sort keys %ints_by_occurrence) {
    my $frequency = $_;
    foreach (sort {$b &amp;lt;=&amp;gt; $a} @{$ints_by_occurrence{$frequency}}) {
        my $number = $_;
        for (1..$frequency) {
            push @results, $number;
        }
    }
}
say $_ foreach @results;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This time we're making a hash of arrays, where %ints_by_occurrence uses frequencies as the key, and an array of numbers as the value. %ints contains the initial histogram which is reversed into %ints_by_occurrence. We sort once by frequency, then we sort each array of a given frequency by value, which is pushed onto the results array in the proper order.&lt;/p&gt;

&lt;p&gt;Those are my solutions to this week's challenge! Hopefully I'll have more for both challenges next week. See you then.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #231 - Not Going to Extremes but Accepting Senior Citizens</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Wed, 23 Aug 2023 13:05:57 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-231-not-going-to-extremes-but-accepting-senior-citizens-39ol</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-231-not-going-to-extremes-but-accepting-senior-citizens-39ol</guid>
      <description>&lt;p&gt;Hi everybody! In this week's weekly challenge, we're searching for anything but the minimum or maximum in a dataset, and searching for senior citizens on a plane.&lt;/p&gt;

&lt;h4&gt;
  
  
  Min And Max
&lt;/h4&gt;

&lt;p&gt;This challenge is a very interesting one, because obviously the easiest solution in terms of development is to sort and filter the first and last element. However, that is O(n log n) and it's very little added complexity to do the O(n) solution with a single-pass filter.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my %hist;
$hist{$_} = 1 for @ARGV;

say "You didn't provide two or more arguments." and exit if scalar keys %hist &amp;lt; 2;
say "-1" and exit if scalar keys %hist == 2;

my ($max, $min);
for (keys %hist) {
    $max = $_ if (!defined($max) || $_ &amp;gt; $max);
    $min = $_ if (!defined($min) || $_ &amp;lt; $min);
}
for (keys %hist) {
    say $_ if $_ != $max and $_ != $min;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;First we make a histogram hash where duplicates are filtered out. Using the histogram, we exit with a failure or -1 if there are 1 or 2 unique numbers left. As we scan the histogram keys we keep track of the minimum/maximum values, then one more pass to print all of them out.&lt;/p&gt;

&lt;h4&gt;
  
  
  Senior Citizens
&lt;/h4&gt;

&lt;p&gt;Contrary to the typical pattern of the second challenge being harder, this one's incredibly simple. We're looking for any senior citizens in a dataset made up of "9999999999A1122”, where 9 denotes the phone number, A the sex, 1 the age and 2 the seat number.&lt;/p&gt;

&lt;p&gt;The simplest way I can think of is substr():&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my $count;
for (@ARGV) {$count++ if substr($_, 11, 2) &amp;gt;= 60}
say $count // 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's it! We just count up every time substr() comes up with someone 60 or over. Then we print out the result.&lt;/p&gt;

&lt;p&gt;That's it for this week! Hopefully I'll be back with another blog post next week.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
      <category>histogram</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #230 - Turning Numbers into Characters and Words into Numbers</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Sun, 20 Aug 2023 09:18:22 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-230-turning-numbers-into-characters-and-words-into-numbers-1o0c</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-230-turning-numbers-into-characters-and-words-into-numbers-1o0c</guid>
      <description>&lt;p&gt;Hi everybody! I'm finally back with another PWC/TWC blog post for week 230.&lt;/p&gt;

&lt;h4&gt;
  
  
  Separate Digits
&lt;/h4&gt;

&lt;p&gt;For the first challenge we want to split all the numbers in the array into single digits. Here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use v5.36;
my @nums;
push(@nums, split(//, $_)) for @ARGV;
say $_ for @nums;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It very simply splits anything in its arguments into individual characters and pushes them onto a new array.&lt;/p&gt;

&lt;h4&gt;
  
  
  Count Words
&lt;/h4&gt;

&lt;p&gt;Our second challenge asks us to count the words that start with the given prefix. Here's a 4-liner (minus boilerplate) to help us out with this one:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use v5.36;
my $pattern = shift;
my $count;
for (@ARGV) {$count++ if $_ =~ /^$pattern/}
say $count // 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We take the pattern and then add to the count if our regex prefix matches the start of any of the strings in the arguments.&lt;/p&gt;

&lt;p&gt;That's all for this week, two nice easy challenges! Hope I'll be able to post again next week maybe.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
    <item>
      <title>Perl v5.36, Debian, and Ubuntu</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Tue, 18 Jul 2023 09:24:17 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-v536-debian-and-ubuntu-3kg2</link>
      <guid>https://dev.to/oldtechaa/perl-v536-debian-and-ubuntu-3kg2</guid>
      <description>&lt;p&gt;I normally only write about the Perl Weekly Challenge/The Weekly Challenge, but today I have a couple things to say about recent Perl versions. I've been watching the videos from TPRC2023, and loving the talk by Paul Evans &lt;a href="https://www.youtube.com/watch?v=nkKuA0UMdEw"&gt;&lt;em&gt;What's New in Perl v5.38&lt;/em&gt;&lt;/a&gt;. I like to have a minimum version in my code generally that I can rely on having all the features from. I think I previously ignored v5.36 because it wasn't in Debian yet (and I typically only use packaged Perl), but thanks to Paul's talk I've really enjoyed looking at the &lt;a href="https://perldoc.perl.org/5.36.0/perldelta"&gt;perldelta&lt;/a&gt;, where some really groundbreaking Modern Perl changes were made just in the use v5.36 syntax.&lt;/p&gt;

&lt;p&gt;Well, now two things have happened. v5.36 is the oldest release still officially supported by the Perl team, and it's in Debian stable. This makes it a great candidate to be my new target version for most code!&lt;/p&gt;

&lt;p&gt;Unfortunately, Ubuntu 22.04 (one of my servers) is still stuck on v5.34, and this makes me sad. 😥&lt;/p&gt;

&lt;p&gt;In related news, the new object system in v5.38 and beyond looks pretty sweet! I'm excited. Can't wait to see what else gets implemented in the next couple versions.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>debian</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #225 - Words to the Max and Diff Sum</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Wed, 12 Jul 2023 10:38:28 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-225-words-to-the-max-and-diff-sum-357p</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-225-words-to-the-max-and-diff-sum-357p</guid>
      <description>&lt;p&gt;Hi all! Back this week with both solutions to The Weekly Challenge for once. We've got a word counting challenge and one that I really don't know how to explain. You have to see the challenge to understand it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Max Words
&lt;/h4&gt;

&lt;p&gt;So this challenge is just to tell us what the longest sentence in a set of sentences is. How many words does it have? A very simple easy solution can follow:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my $highest;
foreach (@ARGV) {
    my @words = split(/ /, $_);
    shift @words if !$words[0];
    $highest = scalar @words if scalar @words &amp;gt; $highest;
}
say $highest;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We take the input sentences (in quotes) and split them by spaces. Now, I tested and splitting by space puts an empty element at the start of the array, so if there is such an empty element we remove it with the shift. Then we check the number of words in this sentence and replace the existing champion if this one is the highest. That one's pretty simple and took just about 15 minutes to write and test.&lt;/p&gt;

&lt;h4&gt;
  
  
  Left Right Sum Diff
&lt;/h4&gt;

&lt;p&gt;No idea what the actual practical purpose of this one is, but it's an interesting challenge and a lot simpler than I initally thought, although I realized in the middle there were some additional cases to handle from what I was thinking.&lt;/p&gt;

&lt;p&gt;The goal is to split a list of integers into &lt;code&gt;@left&lt;/code&gt;, made of &lt;code&gt;(0, $ints[0], $ints[0] + $ints[1], etc.)&lt;/code&gt; and &lt;code&gt;@right&lt;/code&gt;, made of 'etc., $ints[-2] + $ints[-1], $ints[-1], 0)&lt;code&gt;. Then we iterate through and for each pair we take the absolute difference between&lt;/code&gt;$left[$&lt;em&gt;]&lt;code&gt;and&lt;/code&gt;$right[$&lt;/em&gt;]`.&lt;/p&gt;

&lt;p&gt;So here's the code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my @ints = @ARGV;
my (@left, @right, @diff);
push @left, 0;
unshift @right, 0;
if ($#ints) {
    foreach (1..$#ints) {
        push @left, $left[$_ - 1] + $ints[$_ - 1];
        unshift @right, $right[-$_] + $ints[-$_];
    }
}
foreach (0..$#ints) {
    $diff[$_] = abs($left[$_] - $right[$_]);
}
say $_ for @diff;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;First we put the zeros on each list. That's just in case we have a integer list like the second example, with just one number in the list. Then if we have additional integers we count and add numbers to the right side of the &lt;code&gt;@left&lt;/code&gt; list and the left side of the &lt;code&gt;@right&lt;/code&gt; list.&lt;/p&gt;

&lt;p&gt;We loop through both completed lists and we compute the absolute difference, then print the list one-by-one. Voila! Again, not sure what the practical application is, but an interesting challenge. Many thanks to Mohammad and an enjoyable pair of challenges. I also appreciate being the June champion, so you'll hear more of my bio when it's released.&lt;/p&gt;

&lt;p&gt;Have a great week! See you next week.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
      <category>words</category>
    </item>
    <item>
      <title>Perl Weekly Challenge #224 - Passing Notes</title>
      <dc:creator>oldtechaa</dc:creator>
      <pubDate>Wed, 05 Jul 2023 09:35:19 +0000</pubDate>
      <link>https://dev.to/oldtechaa/perl-weekly-challenge-224-passing-notes-3kp5</link>
      <guid>https://dev.to/oldtechaa/perl-weekly-challenge-224-passing-notes-3kp5</guid>
      <description>&lt;p&gt;Hi everybody! Just doing one challenge again this week. Time limitations hold me back once again.&lt;/p&gt;

&lt;p&gt;This week we're looking for the letters of a target word in a source word, and we're not allowed to use the same letter twice. Spoiler alert because it's only Wednesday and you still have the rest of the week to submit solutions if desired.&lt;/p&gt;

&lt;p&gt;The easiest way to do this is with a dictionary hash initialized like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foreach (split //, $source) {$chars{$_}++}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Many people use &lt;code&gt;map()&lt;/code&gt; to do this, but I'm not a big fan of map in many cases because I feel it makes code less readable.&lt;/p&gt;

&lt;p&gt;This gives us the number of occurrences of each letter in the original word.&lt;/p&gt;

&lt;p&gt;Then we iterate through the target word and look for (and remove) the letters in the dictionary:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foreach (split //, $target) {
    if ($chars{$_}) {
        $chars{$_}--;
    } else {
        say 'false' and exit;
    }
}
say 'true';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Obviously if the script did more than just this we'd need a success flag in there instead, but as it is we can just exit if we ever don't find the matching character in the dictionary.&lt;/p&gt;

&lt;p&gt;Anyways, that's the solution for this week! I have a definite idea of how I'd solve the second challenge, I just don't have the time to implement it. I look forward to seeing the other solutions, because I'm sure they'll have more efficient ways to do it.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>perlweeklychallenge</category>
    </item>
  </channel>
</rss>
