Here is a start on a Tk solution. Entries also have a "validatecommand", with which you can pretest the user's text to be valid. You will have to search groups.google.com for "Perl Tk Entry validate" for examples... it can get complex. A Tk::Text widget could also be used, but an Entry widget is simpler for this problem (i.e. no multiline text )
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->fontCreate('medium', -family=>'arial', -weight=>'bold', -size=>int(-14*14/10)); my $frame = $mw->Frame()->pack(); my $bframe = $mw->Frame()->pack(); my $estring = 'C://foo/bar/'; my $lstring = 'Please enter file'; my $label = $frame->Label( -textvariable => \$lstring, -bg => 'white', -width => 25, -justify =>'right', -anchor => 'e', -font => 'medium', )->pack(-side=>'left',-padx=>5); my $entry = $frame->Entry( -textvariable => \$estring, -bg => 'white', -width => 25, -font => 'medium', )->pack(-side=>'left',-padx=>5); $entry->focus; $entry->icursor('end'); $entry->bind('<Return>', \&get_file); $bframe->Button( -text => 'Quit', -command => sub { exit } )->pack(-side=>'left',-padx=>5); $bframe->Button( -text => 'Change', -command => sub { $lstring = 'Enter another'; $estring = 'D://foo/fi/fum/'; $entry->focus; $entry->icursor('end'); } )->pack(-side=>'left',-padx=>5); MainLoop; sub get_file{ my ($widget) = @_; my $entered = $widget->get(); print "file = $entered\n"; }

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: <STDIN> "anticipate" input? by zentara
in thread <STDIN> "anticipate" input? by johnnyjohnny

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.