my @array = qw(foo bar.exe foobar) ; foreach my $string ( @array ) { my @list_of_files = glob /^$string/ ; printf "'%s' => '%s'\n" , $string , join( "','" , @list_of_files ) ; }