<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>weblog.masukomi.org - perl</title>
    <subtitle>Autistic, ADHD, Geek. The weblog of Kay Rhodes (masukomi).</subtitle>
    <link rel="self" type="application/atom+xml" href="https://weblog.masukomi.org/tags/perl/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://weblog.masukomi.org"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2008-04-09T00:00:00+00:00</updated>
    <id>https://weblog.masukomi.org/tags/perl/atom.xml</id>
    <entry xml:lang="en">
        <title>How to create a Test Suite in Perl&#39;s Test::Unit v0.25</title>
        <published>2008-04-09T00:00:00+00:00</published>
        <updated>2008-04-09T00:00:00+00:00</updated>
        
        <author>
          <name>Kay Rhodes</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://weblog.masukomi.org/2008/04/09/how-to-create-a-test-suite-in-perls-testunit-v025/"/>
        <id>https://weblog.masukomi.org/2008/04/09/how-to-create-a-test-suite-in-perls-testunit-v025/</id>
        
        <content type="html" xml:base="https://weblog.masukomi.org/2008/04/09/how-to-create-a-test-suite-in-perls-testunit-v025/">&lt;p&gt;If your Test Case is a package whose goal is to test all aspects of a
particular class then a Test Suite is something which kicks off a
collection of related Test Cases. As with most things in Perl’s Test::Unit it’s
really easy to do and also terribly documented. So, without further
ado… You need something to kick off all your tests:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;perl&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    use&lt;/span&gt;&lt;span&gt; Test::Unit::HarnessUnit;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    use&lt;/span&gt;&lt;span&gt; My::Test::Suite::Package;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-3 z-l-b z-d-6 z-d-b&quot;&gt;    my&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-1&quot;&gt;testrunner&lt;/span&gt;&lt;span&gt; = Test::Unit::HarnessUnit&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;new&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    $&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-1&quot;&gt;testrunner&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;start(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;My::Test::Suite::Package&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next you need the test suite it’s going to kick off:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;perl&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    package&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; My::Test::Suite::Package&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    use&lt;/span&gt;&lt;span&gt; base &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;qw/&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;Test::Unit::TestSuite&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;/&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-l-i z-d-3 z-d-i&quot;&gt;    #&lt;/span&gt;&lt;span class=&quot;z-l-6 z-l-i z-d-3 z-d-i&quot;&gt; returns an array of the fully qualified names of the TestCase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-l-i z-d-3 z-d-i&quot;&gt;    #&lt;/span&gt;&lt;span class=&quot;z-l-6 z-l-i z-d-3 z-d-i&quot;&gt; based classes you wish to run.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-3 z-l-b z-d-6 z-d-b&quot;&gt;    sub&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-1&quot;&gt; include_tests&lt;/span&gt;&lt;span&gt;() &lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;        return&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;Some::Test::Case&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;            &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;Some::Test::Case2&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;            &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;Some::Test::Case3);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-2&quot;&gt;    1;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s it. Happy testing.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Why you shouldn&#39;t dismiss Perl so quickly</title>
        <published>2007-06-23T00:00:00+00:00</published>
        <updated>2007-06-23T00:00:00+00:00</updated>
        
        <author>
          <name>Kay Rhodes</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://weblog.masukomi.org/2007/06/22/why-you-shouldnt-dismiss-perl-so-quickly/"/>
        <id>https://weblog.masukomi.org/2007/06/22/why-you-shouldnt-dismiss-perl-so-quickly/</id>
        
        <content type="html" xml:base="https://weblog.masukomi.org/2007/06/22/why-you-shouldnt-dismiss-perl-so-quickly/">&lt;p&gt;A reader commented that&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;…the syntax of Perl is so hideous and mysterious it produces
unmaintainable code (I know having maintained a multi-tier Perl
webapp).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And, sadly, he’s not the only one that shares that belief. Perl has been
written off by many talented developers because essentially every piece
of Perl code they’ve ever encountered is, well, crap. But, when you get
right down to it you’re basing your opinion of a language based on what
people write with it. It’s like saying that the English language sucks
because there are so many vile and crappy things written in it.&lt;/p&gt;
&lt;p&gt;Perl is quite possibly the most flexible modern programming language.
But, as with anything, &lt;a rel=&quot;external&quot; title=&quot;great power comes with great responsibilty&quot; href=&quot;http://www.newsfromme.com/archives/2005_10_06.html&quot;&gt;great power comes with great responsibility&lt;/a&gt;. Perl geeks believe “&lt;a rel=&quot;external&quot; title=&quot;There&#39;s more than one way to do it.&quot; href=&quot;http://computing-dictionary.thefreedictionary.com/There&amp;#x27;s+More+Than+One+Way+To+Do+It&quot;&gt;There’s more than one way to do
it.&lt;/a&gt;”
where as Python geeks follow a slightly different way&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Python philosophy [is] that “There should be one– and preferably
only one –obvious way to do it.” That is, I can write a multitude
of programs that do exactly the same thing in python in different
styles and methods, but there is only one way that is Pythonic… What
Python does is emphasize a standard quality and method for doing
various tasks instead of just hacking it together. - &lt;a rel=&quot;external&quot; title=&quot;Alexander Botero-Lowry&quot; href=&quot;http://www.geekfire.com/~alex/blog/&quot;&gt;Alexander
Botero-Lowry&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, if you’re working with undisciplined idiots, there’s no question,
choose a language like Python. But, what happens when the Pythonic way
of expressing an idea doesn’t quite mesh with the idea you are trying to
express?&lt;/p&gt;
&lt;p&gt;In Python you’ll generally just have to deal and find a way of
coding what you wanted to express that isn’t very “Pythonic” or that
ends up being more verbose. In Perl there’s probably another handful of
ways to express the same concept. It’s like always having a kick ass
thesaurus available.&lt;/p&gt;
&lt;p&gt;Yes, this means you’ll eventually speak with words
other people aren’t familiar with yet or do things in ways others may
not be so kosher with. But Perl is all about letting you work in
whatever way / style feels best to you. This can obviously lead to
situations where different people don’t agree with how something’s been
implemented even if it’s very sensible. What you need to keep in mind
though, is that the readability and maintainability are the direct
result of the experience, discipline, and consideration given for other
developers by the person writing the code.&lt;/p&gt;
&lt;p&gt;The problem with Perl is that
it makes it incredibly easy for a person with no discipline or limited
experience to express themselves badly… very badly. Combine that with
the fact that it’s so easy to get something that works in Perl when you
haven’t a clue how to code well in any language and the problem just
compounds itself.&lt;/p&gt;
&lt;p&gt;It is very easy to write readable and maintainable
Perl code, but to do so requires discipline. It’s the difference between
giving a kindergartner a generous palette of oil paints and giving one
to Michelangelo. The paint is capable of producing a masterpiece in his
hands, but the kindergartner is just going to make a finger-paintey
mess. Don’t blame the paint. Likewise, don’t blame Perl for the crap
that idiots and newbs produce with it. Instead, go buy them a copy of
&lt;a rel=&quot;external&quot; title=&quot;Code Complete&quot; href=&quot;http://www.amazon.com/Code-Complete-Second-Steve-McConnell/dp/0735619670/&quot;&gt;Code
Complete&lt;/a&gt;
and make every-one’s life a little bit better.\&lt;/p&gt;
&lt;p&gt;And yes, before anyone mentions it, Perl’s OOP tools seem a bit hackish
and can feel bolted on. But once you start to understand how they work
they’re incredibly flexible and let you do things that you couldn’t hope
to touch in Java. And yes, Perl does have a number of funky looking
operators like $# but you really only need to know a few of them. If
you don’t like them you’ll be happy to know that they weren’t too
thrilled with the number of them when they started planning Perl 6.
Speaking of which, there are some truly awesome things that have been
put into Perl 6 and they’ve cleaned up a lot of the syntactic issues
people frequently bitch about…but there will still always be more than
one way to do “it” so you’ll still be able to write ugly code if you
don’t know any better.&lt;/p&gt;
&lt;p&gt;A note about Python: Python rocks. It just has a very different mindset
to Perl. Python isn’t a language for “undisciplined idiots” as I implied
above, but it is a better language to have undisciplined idiots coding
in because while their code may still be crap you’ll at least be able to
read it because of the formatting limitations and the
intentionally limited number of choices for how to do any given thing.&lt;/p&gt;
</content>
        
    </entry>
</feed>
