<?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: Matthew O. Persico</title>
    <description>The latest articles on DEV Community by Matthew O. Persico (@matthewpersico).</description>
    <link>https://dev.to/matthewpersico</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%2F53469%2F985fc523-5328-4d91-be40-b9e93f1dcf7e.jpeg</url>
      <title>DEV Community: Matthew O. Persico</title>
      <link>https://dev.to/matthewpersico</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matthewpersico"/>
    <language>en</language>
    <item>
      <title>Yet Another Perl Switch Statement</title>
      <dc:creator>Matthew O. Persico</dc:creator>
      <pubDate>Wed, 23 Mar 2022 15:56:58 +0000</pubDate>
      <link>https://dev.to/matthewpersico/yet-another-perl-switch-statement-54h3</link>
      <guid>https://dev.to/matthewpersico/yet-another-perl-switch-statement-54h3</guid>
      <description>&lt;p&gt;I am in the middle of a project at my job where we are converting some Perl to Python :-(. In the conversion I was explaining this invocation of a &lt;code&gt;switch&lt;/code&gt; statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight perl"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$thing&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sr"&gt;/ARRAY/&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;some_array_thing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$thing&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;last&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="sr"&gt;/LIST/&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;some_list_thing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$thing&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;last&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="c1"&gt;## default;&lt;/span&gt;
    &lt;span class="nv"&gt;some_scalar_thing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$thing&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After explaining how the &lt;code&gt;for&lt;/code&gt; statement sets &lt;code&gt;$_&lt;/code&gt;, I was asked, "Why not just set &lt;code&gt;$_&lt;/code&gt;?"&lt;/p&gt;

&lt;p&gt;Indeed, why not? You can play with the following code here: &lt;a href="http://tpcg.io/KN9H82"&gt;http://tpcg.io/KN9H82&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight perl"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;strict&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;warnings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="vg"&gt;$_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
    &lt;span class="sr"&gt;/bar/&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;we got bar&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt; &lt;span class="k"&gt;last&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="sr"&gt;/foo/&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;we got foo&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt; &lt;span class="k"&gt;last&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="sr"&gt;/eek/&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;we got eek&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt; &lt;span class="k"&gt;last&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;we dropped through&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;we got foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, my questions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why have I never seen this in any discussion of Perl's &lt;code&gt;switch&lt;/code&gt; synonyms?&lt;/li&gt;
&lt;li&gt;Is there any inherent problem with this?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>perl</category>
      <category>switch</category>
    </item>
    <item>
      <title>Perl Lists - a Partial Taxonomy</title>
      <dc:creator>Matthew O. Persico</dc:creator>
      <pubDate>Tue, 25 May 2021 00:58:54 +0000</pubDate>
      <link>https://dev.to/matthewpersico/perl-lists-a-partial-taxonomy-g8p</link>
      <guid>https://dev.to/matthewpersico/perl-lists-a-partial-taxonomy-g8p</guid>
      <description>&lt;p&gt;&lt;a href="https://phoenixtrap.com/"&gt;Mark Garder&lt;/a&gt; recently published the article &lt;a href="https://phoenixtrap.com/2021/05/18/a-list-of-perl-list-processing-modules/"&gt;A list of Perl list processing modules&lt;/a&gt;, a detailed and factual, unopinionated listing of eight Perl modules that manipulate lists. So, naturally, when his factual, unopinionated listing was cross posted to &lt;a href="https://www.reddit.com/r/perl/comments/nfbhvt/a_list_of_perl_list_processing_modules/"&gt;Redit&lt;/a&gt;, the first comment was the emotional, highly opinionated: &lt;a href="https://www.reddit.com/r/perl/comments/nfbhvt/a_list_of_perl_list_processing_modules/gylv4co?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3"&gt;“So how do we go about fixing this mess? Because it is a mess.”&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Yes, the comment was mine.&lt;/p&gt;

&lt;p&gt;My intent was to see if we could create &lt;em&gt;One List:: To Rule Them All&lt;/em&gt;. Not only does it confuse people who want to learn Perl to have various list functions in different modules (and to have functions that share a name across modules work differently), but it also confuses Perl veterans. &lt;/p&gt;

&lt;p&gt;And yes, once again, that’s me.&lt;/p&gt;

&lt;p&gt;After some consideration, some education and a conversation with the &lt;a href="https://metacpan.org/author/PEVANS"&gt;current maintainer&lt;/a&gt; of &lt;a href="https://metacpan.org/pod/List::Util"&gt;List::Util&lt;/a&gt;, the module of list functions that come with Perl itself, it seemed to me that the first order of operations was to detail just how much of a “mess” this was. So, on Sunday afternoon, while waiting to go to the airport to pick up my son, and while watching Phil Mickelson winning the PGA championship at a record 50 years old, I put together the following spreadsheet:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.google.com/spreadsheets/d/11gI89kOJvm5b30jEWrLaL0D77sZnPKMhMeAP5WcFnzs/"&gt;https://docs.google.com/spreadsheets/d/11gI89kOJvm5b30jEWrLaL0D77sZnPKMhMeAP5WcFnzs/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope that this can serve a as reference for people to see what's available and where it is available. Yes, it may not have a long shelf life,  but I learned a bit more about the state of the &lt;code&gt;List::&lt;/code&gt; namespace. Hopefully, you'll learn a bit too.&lt;/p&gt;

</description>
      <category>perl</category>
      <category>lists</category>
      <category>arrays</category>
      <category>hashes</category>
    </item>
  </channel>
</rss>
