Those are alot of "hows".... its almost like you are asking us to do your homework.

Since you did not give a running code example, your code fragments are not clear if you are nesting subroutines or not.

ensure that $receiptno is updated and data is written to text file only if a new set of data is entered by the user?

There are probably more elegant ways of doing it, but one way is to keep a list of all the $receiptnos that get printed out, and check that list before any new print.

If the idea is to stop multiple simultaneous prints, set the button state to disabled at the start of the print routine, and set back to normal at end of the print sub.

This example shows the idea

#!/usr/bin/perl use warnings; use strict; use Tk; my $FILTER_IS_ON = 0; my $top = new MainWindow(); my $c1 = $top->Button(-text=>$FILTER_IS_ON ? 'turn off' : 'turn on', -command => \&turn)->pack(); my $c2 = $top->Button(-text=> 'Go', -state => 'disabled', -command => sub { print "ook!\n" })->pack(); MainLoop(); sub turn { $FILTER_IS_ON = $FILTER_IS_ON ? 0 : 1; $c1->configure(-text=> $FILTER_IS_ON ? 'turn off' : 'turn on'); $c2->configure(-state=> $FILTER_IS_ON ? 'normal' : 'disabled'); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

In reply to Re: Perl Tk variable update question by zentara
in thread Perl Tk variable update question by perl_seeker

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.