[Users] External library detection script in Perl

Steven R. Brandt sbrandt at cct.lsu.edu
Mon Feb 29 13:57:40 CST 2016

A few minor things...

I wouldn't use the goto to break out of a loop. You can use a loop label 
to do that kind of thing:

  install_search: for my $dir (@dirs) {
     if (defined $install_dir) {
        last install_search;

I like wrapping the script print's in a function, thus,

  message("FFTW3 selected, but FFTW3_DIR not set. Checking some places...");

Multi-line strings can be used.

The function "carp" is usually nicer than "die" because it gives you a 
stack trace (see http://search.cpan.org/dist/perl-5.8.8/lib/Carp.pm).


On 02/29/2016 01:35 PM, Erik Schnetter wrote:
> As discussed earlier today in the telecon, I rewrite the detection
> (but not the build) script of the FFTW3 package in Perl. I attach the
> Perl script for your consumption; otherwise, please look at the "perl"
> branch of this thorn.
> I am pleasantly surprised by the result. The Perl code was easier to
> write than the Bash code. The resulting code is also cleaner and
> easier to read. Support for arrays, scoped variables, and
> differentiating between "empty string" and "undefined variable" help a
> lot. Two 20-line Bash helper scripts turned into 2 lines of Perl each.
> I also took the opportunity to add a few self checks.
> There were only two minor hiccups, namely finding the equivalents of
> "mkdir -p" and "date" in Perl. I solved both easily via Google
> ("make_path", "localtime" / "strftime").
> Finally I want to remark that this script is still stand-alone.
> Translating another script, comparing to Steve's MPI script, and
> looking at Frank's bash_utils should easily identify common functions
> that should be put into a module.
> Steve -- could you as Perl expert do me a favour and scrutinize the
> script for errors or ways to improve it?
> -erik
> _______________________________________________
> Users mailing list
> Users at einsteintoolkit.org
> http://lists.einsteintoolkit.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.einsteintoolkit.org/pipermail/users/attachments/20160229/2835c3d9/attachment.html 

More information about the Users mailing list