Hey all,<br><br>Not sure if anyone here uses Freemind [<a href="http://freemind.sourceforge.net/wiki/index.php/Main_Page">http://freemind.sourceforge.net/wiki/index.php/Main_Page</a>], but I use it quite a bit for brainstorming and as an outliner.<br>
<br>One of the better uses of it for me is to hammer an idea for a perl hash tree very quickly.  The problem is that once I have the hash tree exactly the way I want it in Freemind, I have to manually re-create the hash tree in perl source, with all the required formatting.<br>
<br>This is no longer the case, as I&#39;ve written a quick and dirty &quot;freemind2perl&quot; script (below) which takes a Freemind mindmap file, and converts it into a perl hash tree automagically.  Not sure it will work with all versions of Freemind, but their mindmap files are XML based, and they haven&#39;t really changed it across versions.<br>
<br>Just run this script with &#39;freemind2perl.pl <a href="http://file.mm">file.mm</a>&#39;.  It requires the &quot;XML::Simple&quot; perl module to be installed.<br><br>Again, not sure if anyone here uses Freemind, but I figured I&#39;d share.<br>
<br>#--------------------------------------------------------------------------------<br>#!/usr/bin/perl -w<br><br>use strict;<br><br>use XML::Simple;<br>use Data::Dumper;<br><br>my $xml = new XML::Simple;<br>my $mm_file = shift;<br>
my $data = $xml-&gt;XMLin(&quot;$mm_file&quot;);<br>my $clean;<br><br>sub prep_clean<br>{<br>    my $data = shift;<br>    my $clean;<br><br>    foreach my $key ( keys %{ $data } )<br>    {<br>        if ( $key eq &quot;TEXT&quot; )<br>
        {<br>            $clean-&gt;{$data-&gt;{$key}} = 1;<br>        }<br><br>        if ( $key eq &quot;node&quot; )<br>        {<br>            if ( ref( $data-&gt;{$key} ) eq &quot;HASH&quot; )<br>            {<br>                $clean-&gt;{$data-&gt;{&#39;TEXT&#39;}} = prep_clean(\%{$data-&gt;{$key}});<br>
            }<br><br>            if ( ref( $data-&gt;{$key} ) eq &quot;ARRAY&quot; )<br>            {<br>                my $sub_hashes = {};<br>                for ( my $i = 0; $i &lt;= $#{$data-&gt;{$key}}; $i++)<br>                {<br>
                    foreach my $sub_hash ( \%{ $data-&gt;{$key}[$i] } )<br>                    {<br>                        my $subout = prep_clean( $sub_hash );<br>                        $sub_hashes = { %$sub_hashes, %$subout };<br>
                    }<br>                }<br>                $clean-&gt;{$data-&gt;{&#39;TEXT&#39;}} = $sub_hashes;<br>            }<br>        }<br>    }<br>    return $clean;<br>}<br><br>$clean = prep_clean( \%{ $data-&gt;{&#39;node&#39;} } );<br>
<br>print Dumper(\$clean);<br><br>exit;<br>#--------------------------------------------------------------------------------<br><br clear="all"><br>-- <br>J. Bobby Lopez<br>Web: <a href="http://jbldata.com/">http://jbldata.com/</a><br>
Twitter: <a href="http://www.twitter.com/jbobbylopez">http://www.twitter.com/jbobbylopez</a><br><br>