in reply to Perl/Tk - Dynamic Checkbuttons?

Please post a complete working example that we can run. Make up arrays for the demo like q(a..z). From first glance, it appears you are trying to build variable names, when you should be using hash or an array. See how bad it is to use a variable as a variable name

From a google search:

#!/usr/bin/perl use warnings; use strict; my $part_2 = "Not a good idea"; my $var1 = "part"; my $var2 = "2"; my $compound = eval "\$${var1}_$var2"; print "$compound\n"; __END__ There are three important things to note about this: 1. it is a really bad idea 2. the first $ must be escaped to avoid the first evaluation (the interpolation into the string) 3. $var1 must be in the form of ${var1} because $var1_ is a valid vari +able name
Post a complete minimal example, and we will show you how to use a hash instead. You can make a reference like \$hash{$name} Or if you prefer, arrays can be used like in the following.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; use Encode; my $topdir= shift || '.'; my @subdirs = get_sub_dirs($topdir); my $mw = tkinit(); $mw->geometry('400x400+100+100'); my $sp = $mw->Scrolled('Pane', -scrollbars=>'osoe', sticky=>'nwse') ->pack(-expand=>1, -fill=>'both' ); my @cbvalues; my @cbnames; my $count = 0; foreach my $d( @subdirs){ $cbnames[$count] = $d; $sp->Checkbutton(-text => $d, -font=>[arial => 12], -onvalue => 1, -offvalue => 0, -variable => \$cbvalues[$count], -font => 'big', -bg => 'white', )->pack(-anchor=>'w')->pack(); $count++; } my $showbutton= $mw->Button(-text=>'Show Selected', -bg => 'lightyellow', -command => sub{ my @selected = (); foreach my $c( 0.. $count ){ if ( $cbvalues[$c] ){ push @selected, $cbnames[$c]; } } print "@selected\n"; } )->pack(); MainLoop(); sub get_sub_dirs { my $dir = shift; opendir my $dh, $dir or die "Error: $!"; my @files = grep !/^\.\.?$/, readdir $dh; @files = map { decode( 'utf8', "$dir/".$_ ) } sort @files; closedir $dh; my @sdirs; for my $file ( @files ) { if(-d $file){push @sdirs,$file;} } return @sdirs; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh