use strict; use warnings; my @group1 = ('A','B','C','D'); my @group2 = ('E','F','G','H'); my $string="DEAB CDGHEF"; print "Match: $1\n" while $string =~ /([@group1]{4})/g; #### local $" = ''; #### my @group1 = ('A','B','C','D'); my $char_class1 = join "", @group1; my $string="DEABCDGHEF"; print "Match: $1\n" while $string =~ /([$char_class]{4})/g; #### use strict; use warnings; my @group1 = ('A','B','C','D'); my @group2 = ('E','F','G','H'); my $string="DEABCDGHEF"; local $" = ''; print "Match: $1\n" while $string =~ /([@{[@group1[0..2],@group2[2,3]]}]{5})/g; #### use strict; use warnings; my @group1 = ('A','B','C','D'); my @group2 = ('E','F','G','H'); my $string="DEABCDGHEF"; my $group = join '', @group1[0..2], @group2[2,3]; print "Match: $1\n" while $string =~ /([$group]{5})/g;