$tcl_data =~ s/([^{}\s]+)/'$1',/g; # quote words + comma $tcl_data =~ s/{/[/g; # start list $tcl_data =~ s/}/],/g; # end list + comma #print $tcl_data; my @perl_arr = eval($tcl_data); # interpret as Array of AoAoA... use Data::Dump 'pp'; pp @perl_arr;
thats the output
( [ [ "Register", [ ["CumulativeActive(calls)(In)", 0], ["CumulativeSuccessfullyEstablished(calls)(In)", 0], ["CumulativeSuccessfullyCompleted(calls)(In)", 0], ["CumulativeUnsuccessful(calls)(In)", 0], ], ], ], [ [ ["Make", "Cal", "l"], [ ["CumulativeActive(calls)(In)", 0], ["CumulativeSuccessfullyEstablished(calls)(In)", 0], ["CumulativeSuccessfullyCompleted(calls)(In)", 0], ["CumulativeUnsuccessful(calls)(In)", 0], ], ], ], [ [ "Initiating", [ ["CumulativeActive(calls)(In)", 0], ["CumulativeSuccessfullyEstablished(calls)(In)", 0], ["CumulativeSuccessfullyCompleted(calls)(In)", 0], ["CumulativeUnsuccessful(calls)(In)", 0], ], ], ], [ [ "Summary", [ ["CumulativeActive(calls)(In)", 0], ["CumulativeSuccessfullyEstablished(calls)(In)", 0], ["CumulativeSuccessfullyCompleted(calls)(In)", 0], ["CumulativeUnsuccessful(calls)(In)", 0], ], ], ], )
you might wanna dig in and try to identify "arrays of two element arrays where the first element is a scalar" ( the "definition" of keyed lists), to convert them into hashes in the next step.
Cheers Rolf
( addicted to the Perl Programming Language)
In reply to Re^2: Convert Tcl Keyed List to Perl
by LanX
in thread Convert Tcl Keyed List to Perl
by bkobs39
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |