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

Hello,

simple question again: I want to create arrays in a foreach cycle but always something wrong:

$i = 0; foreach $tab (@tabs) { j = 0; foreach $frnum (@FRs) { $tmp = $tab->Checkbutton(-text => $frnum, -variable => \@tab$i[$j], -command => sub { } )->pack(-side => 'top', -anchor => 'nw'); $j++; } i++; }

I want to create for each tab an array called tab1, tab2, etc that this array could contain all the checkbox variables.

help me, I'm very new. thnaks

Edited by Chady -- fixed formatting.

Replies are listed 'Best First'.
Re: variables
by hbo (Monk) on Jul 20, 2004 at 14:25 UTC
    $tmp = $tab->Checkbutton(-text => $frnum, -variable => \$tab[$i][$j], -command => sub { } )->pack(-side => 'top', -anchor => 'nw');
Re: variables
by bgreenlee (Friar) on Jul 20, 2004 at 14:32 UTC

    You probably want to use:

    -variable => \$tab[$i][$j]

    See perldata, perllol, and perldsc for more info on perl arrays (and other data structures).

    brad

Re: variables
by ambrus (Abbot) on Jul 20, 2004 at 16:33 UTC