Here is a solution to your problem :

use strict; use vars qw/%hash/; use Tk; use Tk::TList; use Tk::HList; my $mw = MainWindow->new(); my $image = $mw->Getimage('folder'); my $tlist = $mw->TList(-orient => 'vertical'); my $label = $mw->Label(-width=>15); my $hlist = $mw->HList( -itemtype => 'text', -separator => '!', -selectmode => 'single', -browsecmd => sub { my $file = shift; $label->configure(-text=> +$file); }); chomp (my @work_file=<DATA>); for (@work_file) { next if ($_ !~ m!,!); @data = split (/[,\s]+/,$_); $ref = \%hash; foreach (@data) { $ref->{$_} = {} if (not defined $ref->{$_}) $ref = $ref->{$_}; } } foreach my $bu (keys %hash) { $hlist->add($bu, -text=>$bu); foreach my $group (keys %{$hash{$bu}}) { $hlist->add("$bu!$group", -text => $group); foreach my $function (keys %{$hash{$bu}->{$group}}) { $hlist->add("$bu!$group!$function", -text => $function); } } } $hlist->pack; $label->pack; MainLoop; __DATA__ Dept Group Function IT, Projects, SAN/NAS IT, Development, GUI IT, Security, HR, Admin, West HR, Management, West Legal, Admin, FirmWide Legal, Compliance,

There are several things to say :


Some things should be improved though. For example, one could use only one pass to create the hlist, that is build the hash and the hlist is the same loop.

HTH

--
zejames

In reply to Re: Displaying a list of hashes in TK in a Hierarchical folder presentation by zejames
in thread Displaying a list of hashes in TK in a Hierarchical folder presentation by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.