X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftry.pl;h=70645492c5f7867483e11646f0aab2900d9b240a;hb=14a44e7b2f834cbd0d2ba8cc63deda55b3e5f0dd;hp=399dbb9554cc12832ac9ba4dff214ed24598fc21;hpb=4c1ada5fa7e7a266479669bdcaa60b33ada4c9c1;p=perl%2Fmodules%2FSub-Op.git diff --git a/samples/try.pl b/samples/try.pl index 399dbb9..7064549 100755 --- a/samples/try.pl +++ b/samples/try.pl @@ -6,13 +6,29 @@ use strict; use warnings; use blib; -use blib 't/Sub-Op-Test'; +use blib 't/Sub-Op-LexicalSub'; my $code = $ARGV[0]; -die "Usage: $0 'code involving f()'" unless defined $code; +die "Usage: $0 'code involving f() and g()'" unless defined $code; -eval <<"CODE"; - use Sub::Op::Test f => sub { say 'f(' . join(', ', \@_) . ')'; \@_ }; - $code +my $cb = eval <<"CODE"; + use Sub::Op::LexicalSub f => sub { say 'f(' . join(', ', \@_) . ')'; \@_ }; + use Sub::Op::LexicalSub g => sub { say 'g(' . join(', ', \@_) . ')'; \@_ }; + sub { $code } CODE die $@ if $@; + +print "--- run ---\n"; +eval { $cb->() }; +warn "exception: $@" if $@; + +print "--- deparse ---\n"; +use B::Deparse; +print B::Deparse->new->coderef2text($cb), "\n"; + +print "--- concise ---\n"; +use B::Concise; +B::Concise::compile($cb)->(); + +print "--- concise(exec) ---\n"; +B::Concise::compile('-exec', $cb)->();