Here's a slightly revamped solution to reduce code redundancy. Anytime you see yourself using variables with digits in them ($charge_1_value, $charge_2_value, etc), what you really want is an array. It saved you much typing space. Here's a revised version of your code:

#!perl -w use strict; use Tk; my $prog_title = 'TESTING'; my $mw = MainWindow->new(); $mw->configure(-background=>'#FFFFFF'); $mw->title($prog_title); $mw->minsize(qw(250 450)); $mw->geometry('+325+150'); my $frame_process = $mw->Frame( -background => '#FFFFFF' )->pack(-side => 'bottom'); $frame_process->Button( -text => 'Process', -command => \&process )->pack(-side => 'top'); my $frame_names = $mw->Frame( -background => '#FFFFFF' )->pack(-side => 'left'); my %fields; for my $index ( 1..10 ) { unshift( @{ $fields{'admission'} }, $frame_names->Text( -width => 20, -height => 1 )->pack(-side => 'bottom') ); $frame_names->Label( -text => 'Admission # ' . (11 - $index), -background => '#FFFFFF' )->pack(-side => 'bottom'); } my $frame_blank = $mw->Frame( -background => '#FFFFFF' )->pack(-side => 'left'); $frame_blank->Label( -text => ' ', -background => '#FFFFFF' )->pack(-side => 'bottom'); my $frame_charge = $mw->Frame( -background => '#FFFFFF' )->pack(-side => 'left'); for my $index ( 1..10 ) { unshift( @{ $fields{'charge'} }, $frame_charge->Text( -width => 12, -height => 1 )->pack(-side => 'bottom') ); $frame_charge->Label( -text => 'Charge', -background => '#FFFFFF' )->pack(-side => 'bottom'); } sub process { my @patients = map { $_->get('1.0', 'end') } @{ $fields{'admission +'} }; my @charge = map { $_->get('1.0', 'end') } @{ $fields{'charge'} }; my @invoice = (@patients, "\n", @charge); print @invoice; } MainLoop;

In reply to Re: Unexpected Error While Retreiving Text in Perl\Tk by saskaqueer
in thread Unexpected Error While Retreiving Text in Perl\Tk by Anonymous Monk

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.