For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > January 2005 > Using a string within a qw construct









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using a string within a qw construct
joe.cipale@radisys.com

2005-01-12, 3:59 pm

I am attempting to build a Tk:Optionmenu pull down from a string that
is passed to a sub-routine from one of my menu items. The string may
look like this:
2 3 8 10 14

The string WILL change, which is why I want to pass the string to my
menu pulldown as such:

my @slt_opt = qw/\$slt/;

$frame3->Label(-text => "Slot ID: ")->pack(-side => 'left',
-anchor => 's',
-expand => 1);

$frame3->Optionmenu(-variable => \$slots,
-options => [@slt_opt],
-command => [sub {print "args=@_\n"}, 'First']);

======================================
Am I reaching with what qw can do here?

Thanks in advance,

Joe

Ala Qumsieh

2005-01-12, 3:59 pm

joe.cipale@radisys.com wrote:
> I am attempting to build a Tk:Optionmenu pull down from a string that
> is passed to a sub-routine from one of my menu items. The string may
> look like this:
> 2 3 8 10 14
>
> The string WILL change, which is why I want to pass the string to my
> menu pulldown as such:
>
> my @slt_opt = qw/\$slt/;


qw() is not what you want. It will split it's argument on whitespace and
quote each element. Checkout 'perldoc perlop' for more details.
You simply want this:

my @slt_opt = (\$slt);

--Ala
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com