use strict; use warnings; my @bah = ( "Australia", "Austria", "Finland", "Norway" ); my $foo = "In Australia the people from Austria drink beer at the pub with the people from Norway"; $foo = lc($foo); my @f; for (@bah) { push @f, $_ if index($foo, lc($_)) != -1; } print join(' ', sort @f), "\n";