Rflatten.pm

Today I wrote a module that I like to use eventually for sending complex data structures with a simple html POST form. Because POST is only Key/Value a flat hash seems to be the way to go. The module now converts:

$VAR1 = [
          'ccc',
          'ddd'
        ];

into this hash:

$VAR1 = {
          ':0' => 'ccc',
          ':1' => 'ddd'
        };

The module knows “:” is an Array element. “.” is used as a hash key. This complex structure:

$VAR1 = {
          'qqqqqq' => [
                        'ccc',
                        {
                          'vvvvv' => 'ddd'
                        }
                      ]
        };

It will convert to:

$VAR1 = {
          '.qqqqqq:0' => 'ccc',
          '.qqqqqq:1.vvvvv' => 'ddd'
        };

The key “qqqqqq” is written in the second key as well. This enables me to create any structure. OK this works but how do you specify a simple Scalar value? I choose this:

 $VAR1 = \'cccc';

converts to:

$VAR1 = {
          'SCALAR' => 'cccc'
        };

‘SCALAR’ can be any word as long as it does not contain “:” or “.”.  I hope to get a http POST example online soon for you all to see and checkout. 


Comments

One Response to “Rflatten.pm”

  1. Post XMLRPC using Rflatten.pm : Broerse Blog on February 3rd, 2008 11:58 pm

    […] Rflatten.pm […]

Leave a Reply