use constant (SYBBATCHSIZE => 1000, # ... ); # ... while( for ( my $i = 0; $i <= $#keys; $i += SYBBATCHSIZE ) { SqlSub( 'DELETE FROM mytable ' . 'where pkcol in ( "' . join( '", "', @keys[ $i ..SYBBATCHSIZE ] ) . '" )' ); }