I have a peculiar problem using module Tkx in combination with module Storable. The purpose is to store all parameters entered by a user in a Tk interface in a file so that it can be loaded the next time when the program is started again.

I have simplified the code here, there is only one parameter $Value and a simple Tk screen with only one entry field linked to $Value. I first store and retrieve $Value and this works OK. Then I change the value with the Tk screen and then things go strange:

my $Value = 666; store( \$Value, 'param.ini' ); # The file viewed in Wordpad shows 'pst0 12345678 ' my $pRPar = retrieve('param.ini'); $Value = $$pRPar; print("$Value\n"); # Prints '666' my $MainWindow = Tkx::widget->new('.'); my $Entry = $MainWindow->new_ttk__entry(-textvariable => \$Value); $Entry->g_grid(-row => 1, -column => 1); Tkx::MainLoop(); # Change the value into '111' and close the window print("$Value\n"); # Prints '111', so this is OK. But... store( \$Value, 'param.ini' ); # The file viewed in Wordpad shows now 'pst0 12345678Tcl:: +Var Tcl^ ::perl::SCALAR(0x3b54b38)'

So the first time the value is stored correctly (if you use a string instead of an integer you will see the string value in the file). The second time you see strange things appear such as 'Tcl::Var' and '::perl::SCALAR(0x3b54b38)'.

Any idea what's happening here?


In reply to Strange behaviour of Tkx in combination with Storable by JanLaloux

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.