@files = ("a1.txt","a2.txt","a3.txt",...."an.txt");#n=50 foreach $file (@files) { my ($h1, $t1) = split(/\./,$file); #use the value of $h1 to create a new array @{$h1}; #to create arrays @a1, @a2, @a3, ....@an }