in reply to foreach problem

The problem is that all four buttons are inside the same loop iteration, so $_ is set to the same thing all four times you call it. What you want is something like this (untested):
my @cols = (); foreach (@files) { $_ =~ s/.*[\/\\](.*)/$1/; push(@cols,td(submit(-name => 'file', -value => $_)); if (@cols == 4) { print Tr({-alien => 'center'}, @cols); @cols=(); } } if (@cols) { while (@cols < 4) { push(@cols,td('&nbsp;')); } print Tr({-alien => 'center'}, @cols); }
That builds up a row, and prints it when it's finished. For the last row, it creates cells with a single non-breaking space in them, which avoids formatting annoyances in some browsers.