foreach (@date){ # create hash reference variable for user inputs as well as every date in array @date $user_input->{pp_branch} = param('pp_branch'); $user_input->{host_name} = param('host_name'); $user_input->{controller} = param('controller'); $user_input->{start_date} = ;#I wann assign here each element of array unless the array gets empty; # .... some code.......... }