rastoboy has asked for the wisdom of the Perl Monks concerning the following question:
I'm not even sure how to phrase this question. I want to get the *location* of a value in a datastructure, as opposed to just seeing if it's there or not.
For example:
will output:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $hash = { base => { key => 'value', key2 => 'value2'}}; print Dumper $hash; my @output = grep $hash, 'value2'; print "@output\n";
But what I really want is like the location of $VAR1=>{'base'}{'key2'}. How can I get that (elegantly)?rasto@sauron:~$ ./test.pl $VAR1 = { 'base' => { 'key2' => 'value2', 'key' => 'value' } }; value2
Any help would be greatly appreciated!
rasto
|
---|