<%args> $foo $bar $baz $biz ... your html code ... deletes += <% $del_count %>; if(deletes > 0) { return confirm('Delete ' . + deletes + . 'Items? '); } ... your html code ... <%init> my @update = split(/,/, $biz); my $del_count = 0; if ($baz == 2 and and{ $tab_id == $_ } @update) { # ??? foreach ($foo, $bar) { $del_count += scalar split(/,/, $_); } }