for my $content(@content) { # my $match = ''; # explicit but verbose # my $match; # still explicit and only slightly less verbose; same effect my ($match) = $content =~ /.+?ABCD(.{10}).*/; # less code; same effect say "Current array element is: $content"; if ($match) { say "\t Next 10 char after the match: $1"; }else{ say "No match on $content"; } }