From: Matt S Trout Date: Sun, 8 Apr 2018 19:01:20 +0000 (+0000) Subject: add "trace *" and introduce a fragment using it to show backtracking X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af4a440ad8875fa12e9934873855e82e2b4a220c;p=scpubgit%2FDX.git add "trace *" and introduce a fragment using it to show backtracking --- diff --git a/fragments/btdemo b/fragments/btdemo new file mode 100644 index 0000000..7ea4adc --- /dev/null +++ b/fragments/btdemo @@ -0,0 +1,9 @@ +trace * +? +eq ?X {{ a 1 b 2 c 3 }} +eq ?Y {{ d 1 e 2 f 3 }} +member_at X ?XKey ?XValue +member_at Y ?YKey ?YValue +eq XValue 2 +eq YValue 2 +... diff --git a/lib/DX/ShellState.pm b/lib/DX/ShellState.pm index c2e9fd2..4374ba4 100644 --- a/lib/DX/ShellState.pm +++ b/lib/DX/ShellState.pm @@ -24,7 +24,8 @@ sub trace_sub { sub { my ($tag, $thing) = @_; my ($part) = split /\./, $tag; - return unless $self->trace_these->{$part} or $ENV{DX_TRACE}; + my $traces = $self->trace_these; + return unless $traces->{$part} or $traces->{'*'} or $ENV{DX_TRACE}; my $dp = deparse($thing); $dp =~ s/\n$//; warn "${dp}\n"; @@ -35,9 +36,9 @@ sub with_trace_changes { my ($self, @changes) = @_; my %trace = %{$self->trace_these}; foreach my $change (@changes) { - if ($change =~ /^\+?(\w+)/) { + if ($change =~ /^\+?(\S+)/) { $trace{$1} = 1; - } elsif ($change =~ /^-(\w+)/) { + } elsif ($change =~ /^-(\S+)/) { delete $trace{$1}; } }