Recent additions to CPAN

Healthy in Old Age

Article from Issue 160/2014
Author(s):

Many people have declared the granddaddy of scripting, Perl, to be dead. A look at new items in the CPAN software repository, however, shows that the community is still quite active.

To paraphrase Friedrich Nietzsche, and may I be forgiven for doing so, "When Zarathustra was alone, however, he spoke thus to his heart: Is it possible? This old saint has not yet heard in his forest that Perl is dead!"

No question: Perl as a programming language has lost some of its significance. Few youngsters today have enough patience to grapple with the admittedly whimsical peculiarities of what used to be the leading scripting language. For years, many users have been moving off in various directions. This does not seem to affect the will of diehard Perl hackers, however. Hardly a day goes by without 50 new module versions appearing on CPAN [1] (Figure 1).

Figure 1: Every day about 50 new module versions land on the CPAN Recent page – striking proof of an active community.

This edition of my column accesses some of the most useful and entertaining modules I stumbled upon while reviewing what the Perl community has released in the past two weeks.

The King's Speech

Converting written text into spoken words requires a speech synthesizer – algorithmically, this is clearly top-level computer science that takes a lot of brain and computing power. Instead of struggling with this itself, the CPAN Speech::Google::TTS module [2] hooks into the multibillion dollar infrastructure of the Google Group by misusing the http://translate.google.com site, where Google provides word-for-word translations of typed text phrases.

But, there's more: At the bottom of the text box is a loudspeaker icon; when clicked, a computer voice dictates the pasted text (Figure 2). The module used in Listing 1 [3] intercepts the sound output and saves it as a .wav file in the /tmp directory. The as_filename() method shows the associated file name, and a call to the MPlayer binary in line 9 plays the spoken text.

Listing 1

text2speech

 

Figure 2: The CPAN Speech::Google::TTS module uses the sophisticated speech synthesizers from the translate.google.com page.

The language is set in line 7 to en for US English. If you have always wanted to end a tough build job acoustically with a crisp "Finish up your coffee break and get back to work!" command, the script now gives you the opportunity to do so. The module also requires the MPlayer package (or a different audio player like mpg123), which Ubuntu installs via apt-get install.

Analyzing Makefiles

You may have experienced that sense of despair when faced with a complicated makefile. The make syntax is not easily understandable, and if a target happens to depend on three others and each of those depends on …, then it can be very difficult to figure out where a potential bug is hiding. The CPAN GraphViz::Makefile module [4] sets out to visualize the dependencies between make targets with the Graphviz package.

In fairness, it must be said that currently GraphViz::Makefile only correctly visualizes toy makefiles: Once the syntax exceeds a certain complexity, the graphs it generates look like a haystack hit by a tornado. However, the makefile (Listing 2) used in the make tutorial [5] for training purposes was neatly processed by GraphViz::Makefile, as the graph generated in Listing 3 shows (Figure 3).

Listing 2

Makefile

 

Listing 3

make2viz

 

Figure 3: The CPAN module GraphViz::Makefile has visualized the makefile from Listing 2.

The Path to PNG

To do this, the constructor in GraphViz::Makefile in line 6 of Listing 3 first accepts an optional GraphViz object. If the parameter is set to undef, GraphViz::Makefile generates its own Graphviz object. The second parameter is set to Makefile, that is, it finds the Makefile in the current directory.

To generate the graph for a target, the generate() method in line 9 accepts the name of the target (in Listing 2, this is all). From here on, the graph is plotted. At the happy ending, the GraphViz->as_png() method saves the graph as makefile.png (Figure 3). The module may be still in its infancy, but its basic concept is quite compelling.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Perl: Heroku

    If you want to put together a web application in your favorite language and publish it for free, you will find Heroku a convenient helper. The service even allows you to bring your own web server.

  • Perl – Programming Tips

    If you have been programming for decades, you've likely gathered a personal bag of tricks and best practices over the years – much like this treasure trove from the Perlmeister.

  • Perl Snapshot: Debugging

    Some developers condemn the use of debuggers, but in many cases, a debugger is a programmer’s last hope. In this Month’s Perl Snapshot, we’ll look at Perl’s integrated debugger.

  • Perl: Collaborate with GitHub

    GitHub makes it easier for programmers to contribute to open source projects by simplifying and accelerating communications between project maintainers and people willing to contribute.

  • Perl: Travis CI

    A new service on travis-ci.org picks up GitHub projects, runs new code through test suites, and notifies the owners if the build fails. Its API enables Perl scripts to gather historical build data, including who-broke-the-build tabulations.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News