Leser: 18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; my @array = qw(a_ a_b_ p_ p.x_); @array = sort{ length $b <=> length $a }@array; my $rx_string = join '|', map{ qr/\Q$_\E/ }@array; my $regex = qr/^($rx_string)/; for my $string ( qw(a_b_file a_test) ) { if ( $string =~ $regex ) { print $1,"\n"; } }