3 use aliased 'DX::Op::FromCode';
4 use aliased 'DX::ArrayStream';
16 my @shells = qw(csh bash);
19 bash => { map +($_ => 1),
20 qw(joe.example.com kitty.scsys.co.uk pryde.scsys.co.uk) },
21 csh => { map +($_ => 1),
22 qw(jim.example.com joe.example.com bob.example.com) },
26 my ($var, $array) = @_;
28 my ($self, $state) = @_;
29 $state->bind_stream_then(
30 $state->scope_var($var),
31 ArrayStream->from_array(@$array),
37 my $op = FromCode->new(
38 code => bind_array(S => \@servers),
39 next => FromCode->new(
41 my ($self, $state) = @_;
42 my $server = $state->scope_var('S')->bound_value;
43 if ($server =~ /\.example\.com$/) {
44 return $state->then($self->next);
46 return $state->backtrack;
51 my %scope = map +($_ => $_), qw(S);
52 my %by_id = map +($_ => DX::Var->new(id => $_)), qw(S);
54 my $state = DX::State->new(
62 while (my $op = $state->next_op) {
63 $state = $op->run($state);
67 is($state->scope_var('S')->bound_value, 'jim.example.com');