TStanley has asked for the wisdom of the Perl Monks concerning the following question:

I am using the Tk module to build a GUI for my QuizTaker.pl program, and I am running into this small error. The GUI itself is fine, but I get this in the command prompt:
Use of uninitialized value in pattern match (m//) at Gui.pl line 18
Now here are lines 17 and 18 of my code:
my $Main=new MainWindow(-height=>'100',-width=>'300',-title=>'QuizTake +r'); $Main->geometry(?\+300,\+300?);
This is being developed on a Windows NT4 Workstation, using ActiveState Perl 5.6.1, Build 626.

TStanley
--------
There's an infinite number of monkeys outside who want to talk to us
about this script for Hamlet they've worked out
-- Douglas Adams/Hitchhiker's Guide to the Galaxy

Replies are listed 'Best First'.
Re: Tk geometry function call
by runrig (Abbot) on Aug 09, 2001 at 04:21 UTC
    The question marks are not part of the syntax. Try:
    $Main->geometry("+300+300");
Re: Tk geometry function call
by dga (Hermit) on Aug 09, 2001 at 02:11 UTC
    $Main->geometry(?\+300,\+300?);

    The question marks are like / marks except that the pattern only matches once until you call reset;

    You will have to quote them or escape them to make it happy.

      I tried this:
      $Main->geometry(\?\+300,\+300\?);
      However, this is what's returned to me:
      search pattern not terminated at GUI.pl line 18
      And when I put it in double quotes like this:
      $Main->geometry("?+300,+300?");
      I get this error:
      bad geometry specifier "?+300,+300?" at C:/Perl/site/lib/Tk/Submethod. +pm line 37

      TStanley
      --------
      There's an infinite number of monkeys outside who want to talk to us
      about this script for Hamlet they've worked out
      -- Douglas Adams/Hitchhiker's Guide to the Galaxy
        What are all these question marks? This is not the format for a geometry in Tk. They usually look something like these:
        $widget->geometry('640x480'); # Big as a VGA Screen $widget->geometry('+100+200'); # Slightly down to the right $widget->geometry('600x800+50+50'); # Big, out of corner
        And other variations. "perldoc Tk::Wm" for more details and options.
Re: Tk geometry function call
by kevin_i_orourke (Friar) on Aug 09, 2001 at 13:52 UTC

    I may be missing what you're trying to do here, so ignore me if I'm wrong.

    The Tk documentation habitually uses ?option? to indicate optional stuff in commands. You don't need (or want) the question marks in your code. This is a bit of a problem due to a lot of the Perl/Tk docs being copied across from Tcl/Tk, some bits don't follow Perl doc conventions.

    Hope this helps,
    Kev

    Kevin O'Rourke