What am I missing?
You are assuming that Button BOK, when calling its own onClick event handler, will pass the text of the Textfield urlfield. This will not work. What *does* get passed is just a copy of the BOK Button object, which you see printing as Win32::GUI::Textfield=HASH(0x1c2c35b). You need to obtain the URL another way.

In the code below, I get the URL by calling the $urlfield->Text() method within the onClick event handler of the BOK Button.
I also made these changes:

Working, tested code:
use strict; use warnings; use Win32::GUI; use Data::Dumper; $Data::Dumper::Useqq = 1; $| = 1; my $main = Win32::GUI::Window->new( -title => 'application', -name => 'Main', -width => 400, -height => 200, -dialogui => 1, ); my $urlfield = $main->AddTextfield( -name => 'urlfield', -text => '', -left => 10, -top => 10, -width => 200, -height => 25, -prompt => ['URL:', 80], -tabstop => 1, ); $main->AddButton( -name => 'BOK', -text => 'GO!', -pos => [148,125], -tabstop => 1, -ok => 1, -onClick => sub { # Either of these work: my $text = $urlfield->Text(); # my $text = $main->urlfield->Text(); SUBMIT( $text ); return 1; }, ); $urlfield->SetFocus(); $main->Show(); Win32::GUI::Dialog(); sub SUBMIT { my ($submitted_url) = @_; print Dumper $submitted_url; } sub Main_Terminate { # -1 = Stop message loop and finish program return -1; }


In reply to Re^3: Passing variables to subroutines and Win32::GUI by Util
in thread Passing variables to subroutines and Win32::GUI by ghettofinger

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.