Sunday, 22 August 2010

perl debugger and perl >5.10 features

I have been using perl >5.10 for a long time and I use give/when and ~~ a lot. But when I try to debug my programs I get annoyed by the fact that I can not use this features in the debugger command line: Why I can not use these features directly in the debugger?? The debugger handle them very well when they are in the code but not in the command line.

This is annoying because I am also get used to use the debugger as a REPL (yes, I know Devel::REPL but I have not installed it everywhere and I usually have a perl debugger already open in my emacs).

After a lot of time avoiding the issue I asked it in stack overflow:

How to use perl 5.10 features inside the debugger?

and eldarerathis explained to me why

perl -dEbug

is not working:

[ eldarerathis]
I found a reference to the issue here, but it's about a year old. However, the relevant portion of the perl source hasn't changed since, and can be seen here.
[...]
Basically, the debugger is loaded before the -E flag is processed, so the features aren't yet enabled when the debugger gets loaded. The gist of this is that you can't currently use -E with the -d command. If you want to use say, switch, or any other feature from the debug prompt, you have to do it like this:
 
  DB<1> use feature 'say'; say "x"
  x

Also seems that feature is lexically scoped so this does not work:

DB<19> use feature 'say'
DB<20> say 1
Number found where operator expected at (eval 41)[/homes/pmg/pmg-soft/local-perl/lib/5.12.1/perl5db.pl:638] line 2, near "say 1"

but this does:

DB<21> use feature 'say';say 1
1

This is annoying because when debuggin perl >5.10 scripts, sometimes I need to fix a given/when, or a line with ~~ or copy-paste a line with say and it does not work :-(.

If someone has any idea how to use new Perl code features in the debugger command line please let me know or answer in stack overflow.

Friday, 23 July 2010

[perl] Rakudo Star will be available at the end of July

Hopefully, Rakudo Star will be released at the end of the month.
http://rakudo.org/node/73

There is also a inline-rakudo (nice!)
http://search.cpan.org/dist/Inline-Rakudo/lib/Inline/Rakudo.pm


A nice excuse to play with perl6 during holidays

Wednesday, 21 July 2010

nice blog entries about GWAS QC checks

Three very nice blog entries from campus coworkers to read:

First two about how to scrutinize GWAS, and one about the sociological, ethical and political issues of giving feedback to the DNA donors:

* [Daniel MacArthur] Serious flaws revealed in "longevity genes" study
* [Jeff Barret] How to read a genome-wide association study
* [Vincent Plagnol] Communicating genetic data to DNA donors


The points of the two first blog entries are relevant to the recent Nature paper
Prepublication data sharing where one of the recommendations of the Toronto International Data Release Workshop is:

Editors and reviewers

As reviewers of manuscripts submitted for publication, scientists should be mindful that prepublication data sets are likely to have been released before extensive quality control is performed, and any unnoticed errors may cause problems in the analyses performed by third parties. Where the use of prepublication data is limited or not crucial to a study's conclusions, the reviewers should only expect the normal scientific practice of clear citation and interpretation. However, when the main conclusions of a study rely on a prepublication data set, reviewers should be satisfied that the quality of the data is described and taken into account in the analysis.

Participants at the Toronto meeting recommended that journals play an active part in the dialogue about rapid prepublication data release (both in their formal guide to authors and informal instructions to reviewers). Journal editors should remind reviewers that large-scale data sets may be subject to specific policies regarding how to cite and use the data. Ultimately, journal editors must rely on their reviewers' recommendations for reaching decisions about publication. However, encouraging reviewers to carefully check the conditions for using data that authors have not created themselves can help to raise both the quality of analysis and fairness in citation of published studies.

If the reviewers start to ask for these checks, studies using big consortium data (WTCCC etc) would be fine but studies would face serious problems if using data from small labs without web page or metadata information availability other than the supplementary information (if any) in a low impact paper. I wonder if would it be possible that resources like EGA , dbGAP or Gen2Phen would have tools to facilitate this checks to the users, referees and readers in the public metadata area (as the data is expected to be in any of these repositories) and have a very 'proactive attitude' asking for this kind of data as complete as possible to the submitter and backing this request with this nature or similar paper.


Finally the image of the Daniel's entry comparing the science longevity paper Manhattan plot vs WTCCC Manhattan plots

dot underscore files in mac tar files

I have found a nasty issue taring files in a mac osX 10.5. When you tar the files sometimes tar creates a '._'  file for each of your files that stores all the metadata (similar to the .files when you copy to a non mac file system)

http://arstechnica.com/apple/reviews/2005/04/macosx-10-4.ars/7

Solution:

add to your bash

[for Tiger]
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true


[for Leopard]
(from http://aaronlongwell.com/2008/05/removing---dot-underscore-file.html)
export COPYFILE_DISABLE=true

Just in case you forgot to skip them, you can prevent the creation at extraction time with:
tar -xzpvf mytarfile.tgz --exclude="._*"

Saturday, 17 July 2010

some nice perl new links

* Interview with Stevan Little (the creator of Moose)
: http://perlcast.com/2010/07/12/stevan-little-on-moose/

* Tim Bunce latest work
** NYTProf now can handle string evals and warn you about $&, $` etc (a must have module)
:: http://blog.timbunce.org/2010/06/09/nytprof-v4-now-with-string-eval-x-ray-vision/
:: http://blog.timbunce.org/2010/07/09/nytprof-4-04-came-saw-ampersand-and-conquered/
** Mirroring successful java classes into perl6
:: http://blog.timbunce.org/2010/07/16/java2perl6api-java-to-perl-6-api-tranalation-what-why-and-whereto/

Sunday, 13 June 2010

blogger html editor is owfully wrong!!!

The blogger html editor is wrong and has evil desires to follow compose mode actions.

Problem: blogger html/compose editor does not understand the css of the blog. So you can not preview your 'class' changes nor see the efects in Compose. Well, this is annoying by does not matter, I can use firebug for doing that and test the final look without publish it.

But where this 'feature' is annoying is in the <pre> vs css: white-space:pre;

If you have any text preformated but using a CSS class with "white-space:pre", that's ok and it works the first time. BUT.... if you try to edit it, it does not see any <pre> tag so it reformats the text and you loose all indentation!!!!

Wednesday, 9 June 2010

ggplot2 course in statistics.com

Dr. Hadley Wickham, the creator the fantastic R library ggplot2 has created an online course at statistics.com:

http://www.statistics.com/ourcourses/ggplot2
price $500

Visualization in R with ggplot2

Aim of Course:

In this course, participants will learn how to use the ggplot R Project to make, format, label and adjust graphs using R. The ggplot2 Project, created by Hadley Wickham, is named after the term "Grammar of Graphics," which was coined by Leland Wilkinson (creator of Systat). This "grammar of graphics" is a system of describing and organizing the fundamental components of a graph and the process of creating a graph. Using ggplot2, participants will learn how to design and implement graphs in an efficient, elegant and systematic manner, following principles of general good graphing practice.

Who Should Take This Course:

Statistical analysts who use R and need to create or modify graphs.

The Instructor:

Dr. Hadley Wickham is the author of ggplot2: Elegant Graphics for Data Analysis (Use R) and a contributor to Cook & Swayne's Interactive and Dynamic Graphics for Data Analysis: Using R and GGobi (2007). His research interests include interactive and dynamic graphics, developing practical tools for data analysis, and in gaining better understanding of complex statistical models through visualization. An Assistant Professor at Rice University, Dr. Wickham has developed 15 R projects, and written numerous articles, chapters, and other papers and in 2006 he won the John Chambers Award for Statistical Computing for his work on the ggplot and reshape R packages.

Saturday, 5 June 2010

tree map of the top 500 supercomputers

http://news.bbc.co.uk/2/hi/technology/10187248.stm


A nice tree map for visualizing different aspects of the the top500 supercomputers.

A history of treemaps

HTML5 and CSS3

A nice report of the current state of the HTML5 and CSS3 status in the main browsers

http://html5readiness.com/#ray-7

 Chrome and Safary missing 2 features, opera 4, firefox 8 and ie 'a lot'

Tuesday, 1 June 2010

[perl] playing with Test::Trap

In my previous post I was experimenting with Test::Exception. And as I wanted more flexibility reporting the errors (capturing $@) I am now exploring Test::Trap.

Test::Trap has more control about trapping exceptions. It captures them in a object called by default $trap

I have created the next code to test how Test::Trap stores the exceptions and how to retrieve them:

!/usr/bin/env perl


=head1 [progam_name]

 description:

=cut

use strict;
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use warnings;
use Data::Dumper;
use Test::More;
use Test::Trap;

plan tests => 3;

my $ok;
my $like_ok;

$ok = trap {exception('die1')};

# testing
$like_ok = like($trap->die, qr/cause1/, 'testing exception("die1")');
$like_ok? diag(debug_exception_ok($trap->die,3))
        : diag($ok? "not died but return: $ok" : 'died with: '.$trap->die());

# testing
$like_ok = like($trap->die, qr/cause2/, 'testing exception("die1")');
$like_ok? diag(debug_exception_ok($trap->die,3))
        : diag($ok? "not died but return: $ok" : 'died with: '.$trap->die());

$ok = trap {exception('live')};
like($trap->die, qr/cause1/, 'testing exception("live") ');
$like_ok? diag(debug_exception_ok($trap->die,3))
        : diag($ok? "not died but return: $ok" : 'died with: '.$trap->die());

sub exception {
    my $txt = shift;
    $txt eq 'die1'? throw "cause1" : return $txt;
}

sub debug_exception_ok{
    my $txt = shift;
    my $num = shift;
    #$DB::single=1;
    # add the [ok] to help the output to be taken as ok
    my $msg = '[ok] ' . join ("\n[ok] ",(split "\n",$txt)[0..($num-1)]);
    return $msg;
}

* The first test was ok:
$ok = trap {exception('die1')};

# testing
$like_ok = like($trap->die, qr/cause1/, 'testing exception("die1")');
$like_ok? diag(debug_exception_ok($trap->die,3))
        : diag($ok? "not died but return: $ok" : 'died with: '.$trap->die());

== output ==
ok 1 - testing exception("die1")
# [ok]
# [ok] -------------------- EXCEPTION --------------------
# [ok] MSG: cause1

* the second test, when dying not by the condition tested but by another, then it is a bit over-verbose.
not ok 2 - testing exception("die1")
#   Failed test 'testing exception("die1")'
#   at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 31.
#                   '
# -------------------- EXCEPTION --------------------
# MSG: cause1
# STACK main::exception /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:42
# STACK main::__ANON__[/nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23] /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:103] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:100
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:112] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:87] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:84
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:147] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:146
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::Builder::trap /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:39] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:38
# STACK toplevel /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23
# ---------------------------------------------------
# '
#     doesn't match '(?-xism:cause2)'

[until here is the like() output: as it fails it prints the $trap->die. The thing
that I don't like is that the regex tested is at the end of the ouptut]

[now prints the 'cause of death' after the regex tested]
# died with:
# -------------------- EXCEPTION --------------------
# MSG: cause1
# STACK main::exception /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:42
# STACK main::__ANON__[/nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23] /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:103] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:100
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:112] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:87] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:84
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:147] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:146
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::Builder::trap /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:39] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:38
# STACK toplevel /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:23
# ---------------------------------------------------


The problem with this second test with Test::Trap is that the throw() is over-verbose, and gets printed twice if I want to modify the exception output stored in Test::Trap object.

One solution is report the test in a if..else. This is less elegant but do the job:
# testing
if (like($trap->die, qr/cause2/, 'testing exception("die1") for exception cause2') ){
    diag(debug_exception_ok($trap->die,3));
}
elsif($ok){
    diag( "not died but return: $ok");
}

#== output ==
not ok 2 - testing exception("die1") for exception cause2
#   Failed test 'testing exception("die1") for exception cause2'
#   at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 34.
#                   '
# -------------------- EXCEPTION --------------------
# MSG: cause1
# STACK main::exception /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:49
# STACK main::__ANON__[/nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:22] /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:22
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:103] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:100
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:112] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:109
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:87] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:84
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::Builder::TempFile::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:33] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder/TempFile.pm:32
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:306] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:305
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:147] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:146
# STACK Test::Trap::Builder::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:276
# STACK (eval) /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::Builder::trap /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap/Builder.pm:88
# STACK Test::Trap::__ANON__[/nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:39] /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Trap.pm:38
# STACK toplevel /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t:22
# ---------------------------------------------------
# '
#     doesn't match '(?-xism:cause2)'


* Finally if the tested subrutine does not die, then the like() regular expression for the exception is in void scalar and raise a warning (not elegant)
$ok = trap {exception('live')};
like($trap->die, qr/cause1/, 'testing exception("live") ');
$like_ok? diag(debug_exception_ok($trap->die,3))
: diag($ok? "not died but return: $ok" : '');

#== output==
Use of uninitialized value in pattern match (m//)
at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 36.
at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 36
eval '
#line 36 /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t
$test = $this =~ /$usable_regex/ ? 1 : 0
;' called at /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Builder.pm line 1119
Test::Builder::_regex_ok('Test::Builder=HASH(0x9ba6a0)', 'undef', 'Regexp=SCALAR(0xf39f50)', '=~', 'testing exception("live") ') called at /nfs/users/nfs_p/pg4/local_perl/perllib/Test/Builder.pm line 803
Test::Builder::like('Test::Builder=HASH(0x9ba6a0)', 'undef', 'Regexp=SCALAR(0xf39f50)', 'testing exception("live") ') called at /nfs/users/nfs_p/pg4/local_perl/perllib/Test/More.pm line 416
Test::More::like('undef', 'Regexp=SCALAR(0xf39f50)', 'testing exception("live") ') called at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 36
not ok 3 - testing exception("live")
# Failed test 'testing exception("live") '
# at /nfs/users/nfs_p/pg4/programming/perl/playing_with_test_trap.t line 36.
# undef
# doesn't match '(?-xism:cause1)'
# not died but return: live


I need the ' : diag($ok? "not died but return: $ok" : ''); ' in order to highligth that the die does not happen as expected and there would be an error in the sub or in the test itself.

To sum up, despite the Test::Trap seems more flexible, Test::Exception just do the job clean and easier with Throws_ok