in reply to Re^2: Parsing Data Help!
in thread Parsing Data Help!

Here is one way:
sub findcd { my $someref = shift; my $type = ref($someref); if( $type eq "" ) { # do nothing for non-references } elsif( $type eq "ARRAY" ) { foreach my $elem (@{$someref}) { findcd( $elem ); } } elsif ($type eq "HASH" ) { foreach my $elem (keys %{$someref}) { print "cd: $$someref{$elem}\n" if $elem eq "cd"; findcd( $$someref{$elem} ); } } else { warn "Cannot deal with $type.\n"; } } findcd( $p );
but I am sure there is a module doing it simpler.
For every complex problem there is an answer that is clear, simple, and wrong. H. L. Mencken

Replies are listed 'Best First'.
Re^4: Parsing Data Help!
by Anonymous Monk on Mar 15, 2013 at 15:44 UTC
    You are right, its not flat,I need a module to do this or flat the data somehow.