sub A { ... foreach $key(@some array) # eg: array contains values like Sunday, Monday , Tuesday..etc { ... ... ... push(@{$key[0]}, #some values); #create dereferenced array push(@{$key[1]}, #some values); #eg: Monday has # @Monday = ([1,23,4,8,], # [12,58,77,9]); .. .. # what do i do here ?? } sub B #to be called by the user after running the sub A for the first time { .. print "Enter the day to be plot: "; $a = <>; #this value is to be matched to the array name i.e Monday to be plotted, .. # once the corresponding array is found , we plot the values }