Yep, that works fine. ${something} is the same as $something, except that
the {} seperates the variable name "something" from whatever follows. Both
your solutions do the same. That's the beauty and curse of Perl, there are
always 1001 ways to do it.

> -----Original Message-----
> From: Ceres [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 19, 2002 10:35
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: [perl-win32-gui-users] Re: Perl-Win32-GUI-Users digest, Vol 1
> #425 - 3 msgs
> 
> 
> 
> ##                 ______         ##
> ## $subname = "Menu${key}_Click"; ##
> ##                 ^^^^^^         ##
> 
> is this working  ?
> scalar $key is a string and has a value
> but does ${key} have the same value then?
> isn't it interpated as a hash in stead of a scalar?
> 
> i mostly use:
>   $subname = "Menu$key\_Click";
> or
>   $subname = "Menu$key"."_Click";
> 
> Grretings
>   Ceres
> 
> *********** REPLY SEPARATOR  ***********
> 
> On 18-6-2002 at 12:11 
> [EMAIL PROTECTED] wrote:
> 
>  > Today's Topics:
>  > 
>  >    1. Creating menu's "on-the-fly" (Jonathan Southwick)
>  >    2. Fwd: Re: [perl-win32-gui-users] Creating menu's 
> "on-the-fly" (Jonathan Southwick)
>  >    3. Re: Creating menu's "on-the-fly" (Jonathan Southwick)
>  > 
>  > --__--__--
>  > 
>  > Message: 1
>  > From: Jonathan Southwick <[EMAIL PROTECTED]>
>  > Subject: [perl-win32-gui-users] Creating menu's "on-the-fly"
>  >
>  > Can anyone see anything I  am doing wrong?
>  > 
>  > # define main menu
>  > my $MainMenu = new Win32::GUI::Menu(
>  >      "&File" => "File",
>  >      "   >   E&xit" => "FileExit",
>  >      "&Message" => "Message",
>  >      "   >   &Add New" => "AddMessage",
>  >      "   >   &Edit" => "EditMessage",
>  >      "   >   &Delete" => "DeleteMessage",
>  >      "   >   -" => 0,
>  >      @MENUDEF,
>  >      "&Tools" => "Tools",
>  >      "   >   &Setup" => "Setup",
>  >      "   >   -" => 0,
>  >      "   >   Change &Password" => "ChangePassword",
>  >      "&Help" => "Help",
>  >      "   >   &About" => "About",
>  > );
>  > 
>  > 
>  > ### I call this routine *before* I create my menu.
>  > sub getMessageList {
>  >   ### stuff deleted, this section just read in the file 
> and created the has
>  >   ### now I want to use the values in the hash for my menu.
>  >     @MENUDEF = ();
>  >     foreach $key (keys (%MESSAGE)) {
>  >        print "$key is text: $MESSAGE{$key}\n";
>  >      ## this is only for testing purposes to make
>  >      ## sure I have the right information
>  >        push(@MENUDEF," > $key");
>  >        push(@MENUDEF,"Menu$key");
>  >        $subname = "Menu${key}_Click";
>  >        *$subname = eval(qq(
>  >           sub {
>  >              print "got a click\n"; ## this is for 
> testing, but I don't get a click
>  >              $MainWindow->Message->Text($MESSAGE{$key});
>  >              return;
>  >           }
>  >        ));
>  >     }
>  >     return;
>  > }
>  > 
>  > 
>  > Jonathan
> 
> 
> 
> --------------------------------------------------------------
> --------------
>                    Bringing you mounds of caffeinated joy
>                    >>>     http://thinkgeek.com/sf    <<<
> 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> 

Reply via email to