Wise Ones!,
I am having a little trouble with perl/tk. I have only just started using it and I am finding it difficult to process some text entry through clicking a button.
I basically have a .pm file with a sub called 'collect', this is referenced in the code below. I need to basically pass whatever is entered in the IP text box to collect, so I thought collect($ipadde) would do the trick...apparently not!
Is there anyone who can give me a hand plz?

use Tk; use Tk::Label; use Tk::Photo; use Tk::Text; use Tk::Notebook; # module that is referenced use saracen_collect; my $mw = MainWindow->new; $mw->title("Data Collection - Saracen"); $mw->MainWindow->Frame(-relief=>'groove'); $mw->minsize(600,300); my $image = $mw->Photo(-file => "saraLogo2.gif"); $mw->Label(-image => 'image1')->pack(-side=> "left", -anchor => 'n'); my $tittle = $mw -> Label(-font => '16', -text => "Specify Host:")->pa +ck(-side => 'top', -anchor => 'w'); my $inp = $mw -> NoteBook(-ipady => '4', -borderwidth => 2, -relief => + 'flat')->pack(-side => 'left', -anchor => 'nw', -side => 'left'); my $tab1 = $inp->add( "Sheet 1", -label=>" IP "); my $f1 = $tab1 -> Frame(-relief => 'flat')->pack(-side => 'top', -anch +or => 'nw'); my $ipaddl = $f1 -> Label(-text => "IP ADDRESS:\t\t\t")->pack(-side => + 'left', -anchor => 'nw'); my $ipadde = $f1 -> Entry(-borderwidth => '5',-background => 'white')- +>pack(-side => 'right', -anchor => 'nw'); my $f2 = $tab1 -> Frame(-relief => 'flat')->pack(-side => 'bottom', -a +nchor => 'sw'); my $confpwdl = $f2 -> Label(-text => "CONFIRM PASSWORD:\t\t")->pack(-s +ide => 'left', -anchor => 'nw'); my $confpwde = $f2 -> Entry(-borderwidth => '5',-background => 'white' +)->pack(-side => 'right', -anchor => 'nw'); my $f3 = $tab1 -> Frame(-relief => 'flat')->pack(-side => 'bottom', -a +nchor => 'sw'); my $pwdl = $f3 -> Label(-text => "PASSWORD:\t\t\t")->pack(-side => 'le +ft', -anchor => 'nw'); my $pwde = $f3 -> Entry(-borderwidth => '5',-background => 'white')->p +ack(-side => 'right', -anchor => 'nw'); my $f4 = $tab1 -> Frame(-relief => 'flat')->pack(-side => 'bottom', -a +nchor => 'sw'); my $userl = $f4 -> Label(-text => "USER NAME:\t\t\t")->pack(-side => ' +left', -anchor => 'nw'); my $usere = $f4 -> Entry(-borderwidth => '5',-background => 'white')-> +pack(-side => 'right', -anchor => 'nw'); my $bf = $mw-> Frame(-pady => '5')->pack(-side => 'bottom', -anchor=>' +se'); my $cancel = $bf -> Button(-relief=> 'raised', -borderwidth => '2', -t +ext => "Cancel", -command => sub {exit;})->pack(-side => 'right',-pad +x => '20'); # It is here I am trying to make the button process the sub. my $next = $bf -> Button(-relief=> 'raised', -borderwidth => '2', -tex +t => "Finish", -command => sub {collect(\$ipadde); exit;})->pack(-sid +e => 'right'); MainLoop;

Cheers, Steve


In reply to Perl/Tk processing entered text with button 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.