use strict; while(<*.*>) { $extension =~ /\.([^\.]+)$/g; push(@extarray, $1); } print join("\n", @extarray);