#!/usr/bin/perl my @b; for my $i ( 1 .. 5 ) { $b[$i] = $top->Button( -text=>$i, -command=> &mybuttons($i), ^^^^^^^^^^^^^^^^ WRONG # Stephen O. Lidie writes: # -command expects a *code reference*, that shall, at some future time, # execute. You've called for an immediate execution, which in theory could # return a code ref, but doesn't here. # Ya'all all are skrting around a closure, which may be created in various # ways, all detailed in you know what. # Try: -command => sub {&mybuttons($i)} #or maybe: -command => [\&mybuttons, $i]