# Assuming $_ contains the input: my @hebrew_parts = /\p{Hebrew}+/g; my @arabic_parts = /\p{Arabic}+/g; my @greek_parts = /\p{Greek}+/g;