Devel-Optic
view release on metacpan or search on metacpan
"find me!"
A less specific query on the same data structure:
%my_cool_hash->{'a'}
Will return that branch of the tree:
["blub", { needle => "find me!", some_other_key => "blorb" }]
Other syntactic examples:
$hash_ref->{'a'}->[0]->[3]->{'blorg'}
@array->[0]->{'foo'}
$array_ref->[0]->{'foo'}
$scalar
#### QUERY SYNTAX ALTNERATIVES
The query syntax attempts to provide a reasonable amount of power
for navigating Perl data structures without risking the stability of the system
under inspection.
In other words, while `eval '$my_cool_hash{a}->[1]->{needle}'` would
be a much more powerful solution to the problem of navigating Perl data
structures, it opens up all the cans of worms at once.
The current syntax might be a little bit "uncanny valley" in that it looks like
Perl, but is not Perl. It is Perl-ish. It also might be too complex, since it
allows fancy things like nested resolution:
$foo->{$bar}
Or even:
%my_hash->{$some_arrayref->[$some_scalar->{'key'}]}->{'needle'}
Ouch. In practice I hope and expect that the majority of queries will be
simple scalars, or maybe one or two chained hashkey/array index lookups.
I'm open to exploring other syntax in this area as long as it is aligned with
the following goals:
- Simple query model
As a debugging tool, you have enough on your brain just debugging your system.
Second-guessing your query syntax when you get unexpected results is a major
distraction and leads to loss of trust in the tool (I'm looking at you,
ElasticSearch).
- O(1), not O(n) (or worse)
I'd like to avoid globs or matching syntax that might end up iterating over
unbounded chunks of a data structure. Traversing a small, fixed number of keys
in 'parallel' sounds like a sane extension, but anything which requires
iterating over the entire set of hash keys or array indicies is likely to
surprise when debugging systems with unexpectedly large data structures.
# SEE ALSO
- [PadWalker](https://metacpan.org/pod/PadWalker)
- [Devel::Probe](https://metacpan.org/pod/Devel::Probe)
( run in 2.932 seconds using v1.01-cache-2.11-cpan-5735350b133 )