]> git.vpit.fr Git - perl/modules/Sub-Op.git/blobdiff - samples/try.pl
Rename Sub::Op::Test to Sub::Op::LexicalSub
[perl/modules/Sub-Op.git] / samples / try.pl
index 399dbb9554cc12832ac9ba4dff214ed24598fc21..70645492c5f7867483e11646f0aab2900d9b240a 100755 (executable)
@@ -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)->();