title: In Perl, how can query a JSON::Path object and return the paths of the matched elements?
body: <p>I have a json structure loaded on to a hash, like this:</p>
  <pre><code>my $data = {
   &quot;store1&quot; =&gt; {
     &quot;book&quot; =&gt; [ 
       { &quot;category&quot; =&gt;  &quot;reference&quot;,
         &quot;author&quot;   =&gt;  &quot;Nigel Rees&quot;,
         &quot;title&quot;    =&gt;  &quot;Sayings of the Century&quot;,
         &quot;price&quot;    =&gt;  8.95,
       },
       { &quot;category&quot; =&gt;  &quot;fiction&quot;,
         &quot;author&quot;   =&gt;  &quot;Herman Melville&quot;,
         &quot;title&quot;    =&gt;  &quot;Moby Dick&quot;,
         &quot;isbn&quot;     =&gt;  &quot;0-553-21311-3&quot;,
         &quot;price&quot;    =&gt;  8.99,
       },
     ],
     &quot;bicycle&quot; =&gt; [
       { &quot;color&quot; =&gt; &quot;red&quot;,
         &quot;price&quot; =&gt; 19.95,
       },
     ],
   },
   &quot;store2&quot; =&gt; {
     &quot;book&quot; =&gt; [ 
       { &quot;category&quot; =&gt;  &quot;reference&quot;,
         &quot;author&quot;   =&gt;  &quot;Nigel Rees&quot;,
         &quot;title&quot;    =&gt;  &quot;Sayings of the Century&quot;,
         &quot;price&quot;    =&gt;  8.95,
       },
       { &quot;category&quot; =&gt;  &quot;fiction&quot;,
         &quot;author&quot;   =&gt;  &quot;Herman Melville&quot;,
         &quot;title&quot;    =&gt;  &quot;Moby Dick&quot;,
         &quot;isbn&quot;     =&gt;  &quot;0-553-21311-3&quot;,
         &quot;price&quot;    =&gt;  8.99,
       },
     ],
     &quot;bicycle&quot; =&gt; [
       { &quot;color&quot; =&gt; &quot;red&quot;,
         &quot;price&quot; =&gt; 19.95,
       },
     ],
   },
  
  };
  </code></pre>
  <p>Tools like JSON::Path, return the values of the elements matching the path.</p>
  <pre><code>my $jpath   = JSON::Path-&gt;new('$.*.book[*]');
  my @books   = $jpath-&gt;values($data);
  </code></pre>
  <p>I would like to get the Paths, not the values. Something like:</p>
  <pre><code>[
  '$-&gt;{store}{book}[0]',
  '$-&gt;{store}{book}[1]',
  '$-&gt;{store}{book}[2]'
  ]
  </code></pre>
  <p>I want to find information in the Path, in order to know the location of the results and not the results themselves.
  For example, given the query:</p>
  <pre><code>my $jpath   = JSON::Path-&gt;new('$.*.book[*]');
  </code></pre>
  <p>I would like to know if the Path contains &quot;store1&quot; or &quot;store2&quot;, so I need the query to return the Paths.</p>
  <p>Is there a way to do this?</p>
  <p>Thanx,
  Spiros</p>