Skip to content

Instantly share code, notes, and snippets.

@jjl
Created November 17, 2012 17:21
Show Gist options
  • Save jjl/4097832 to your computer and use it in GitHub Desktop.
Save jjl/4097832 to your computer and use it in GitHub Desktop.
use strict;
sub foo {
interceptive_block {
bar();
} intercept(baz => $baz) {
//$baz = 'baz'
}
}
sub bar {
pass_upward(baz => "baz");
}
@jjl
Copy link
Author

jjl commented Nov 17, 2012

package intercept;
our $test_value;

package A;
sub foo {
local $intercept::test_value = undef;
B::bar();
if (defined $intercept::test_value) {
print $intercept::test_value;
} else {
die("Didn't work");
}
}

package B;

sub bar {
$intercept::test_value = 'baz';
}

package main;
A::foo();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment