#!/usr/bin/env perl
use strict;
SOME_LOOP:
for my $outer (1..2) {
print "outer: before callback with $outer\n";
call_my_callback( sub { next SOME_LOOP } ); # you say this should advance "$outer";
print "outer: after callback with $outer\n";
}
sub call_my_callback {
SOME_LOOP:
for my $inner (1..2) {
print "inner: before callback with $inner\n";
$_[0]->(); # "neeeexxxt!"
print "inner: after callback with $inner\n";
}
}
####
outer: before callback with 1
inner: before callback with 1
inner: before callback with 2
outer: after callback with 1
outer: before callback with 2
inner: before callback with 1
inner: before callback with 2
outer: after callback with 2
####
outer: before callback with 1
inner: before callback with 1
outer: before callback with 2
inner: before callback with 1