The basic representation of my prog:
my %file_system = ( '/path/subpath1/'=>['file1', 'file2', 'file3'], '/path/=>['fil01', 'fil02', 'fil03', 'fil04', 'fil05'], '/'=>['f001', 'f002'] ); my $cpath = ''; my @folders = sort keys %file_system; for my $folder (@folders){ print "$file_system{$folder}\n"; #Everythng is ok. Prints an array re +fernce, such as: ARRAY(0x3381e118) print join(';', @{$file_system{$folder}}), "\n"; #Everythng is ok. Pr +ints an array } my $listFolders = $win->BrowseEntry( -label=>'Folder:', -choices=>[@folders], #Also tried \@folders, and also, omitting -choi +ces parameter, used $listFolders->insert('end', @folders) -variable=>\$cpath, -browsecmd=>\&listFiles(); )->pack( -side=>'top', -anchor=>'nw', -fill=>'x', -expand=>1 ); #Testing $cpath, after selection: print "$file_system{$cpath}\n"; #Sometimes prints an array refernce, s +uch as: ARRAY(0x3381e118), sometimes not, even, though, visually, the + $cpath looks the same as the according path in the %fule_system var print join(';', @{$file_system{$folder}}), "\n"; #Sometime prints an a +rray, sometimes an array is NULL. #If I iterate keys %file_system, I see the path, that's in $cpath var, + but for some reason, it doesn't match. #Testing $cpath inside the function called from the Tk widget: sub listFiles{ print "$file_system{$cpath}\n"; #Sometimes prints an array refernce, +such as: ARRAY(0x3381e118), sometimes not, even, though, visually, th +e $cpath looks the same as the according path in the %fule_system var print join(';', @{$file_system{$folder}}), "\n"; #Sometime prints an +array, sometimes an array is NULL. }

Seems, like, sometimes, for some reason, -variable in the BrowseEntry returns the corrupt value, that doesn't match as a key in the original var, although, visually, looks the same, as in the original hash.

Update:

Devel::Peek helped me to reveal that, indeed, it was an encoding problem, as Corion noted. I implicitly set an encoding and the problem went away


In reply to maybe, a corrupt selected entry in Tk::BrowseEntry by igoryonya

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.