Interleaved lists and associative arrays



Hi, all,

I need write Tcl code to interactive with a Perl module. Perl may pass
me something like the following::

{
[
{ url => 'http://foo.org', title => 'The Foo Organsiation' }
{ url => 'http://bar.org', title => 'The Bar Organsiation' }
],
[
{ url => 'http://foo.org', title => 'The Foo Organsiation' }
{ url => 'http://bar.org', title => 'The Bar Organsiation' }
]
}

[] is equivalent to the Tcl list. However, I cannot find the Tcl
equivalence for {} (associative arrays). I know that Tcl has array
variables, which implement associative arrays. But it seems that array
variables cannot be embedded into a Tcl list. See the following
example:

% set webpage1(url) http://foo.org
http://foo.org
% set webpage1(title) http://foo.org
http://foo.org
% [list $webpage1]
can't read "webpage1": variable is array

Can any one shed some light on this problem? I am kind of stuck right
now.

Thanks a lot!

Best regards,
Jingzhao

.



Relevant Pages

  • Re: function and structures
    ... C code and i have to rewrite the code in TcL. ... is to assign to it with a set command (or some other commands such ... probably the best way is to use a Tcl array. ... Functions are declared with the proc command: ...
    (comp.lang.tcl)
  • Re: function and structures
    ... lines,, i want to implement the same in TcL. ... is to assign to it with a set command (or some other commands such ... probably the best way is to use a Tcl array. ... Functions are declared with the proc command: ...
    (comp.lang.tcl)
  • Re: Question concerning object-oriented programming
    ... Dispose has to do with releasing unmanaged resources (though there are ... printable and readable string in all human languages. ... What the [array get] does is create a list, and then the list has its ... I also wrote my own data structure code in C as a loadable Tcl ...
    (comp.programming)
  • Re: 2D arrays simulated using lists
    ... I would be very sad to see you believe Tcl doesn't meet your ... of index, so I'm comparing the indexes at first, then I'm comparing ... using [array set] because I thought that it would make the whole ... array set ListeActuelleAgents [list ...
    (comp.lang.tcl)
  • Re: Help! mem leak in c extension.
    ... But I guess the non specificity of the progs and specially the ... through simple disciplines of measurement and ... array as a tcl array or as a list. ...
    (comp.lang.tcl)