You are right but the sets of patterns can include any number of patterns which will mean a variable number of foreach loop and I don't know how to achieve. thanks oznur
Ok, welcome to the wonderful world of dynamic code generation. The code below is ugly as sin, but see if it does what you want.
#!/usr/bin/perl
use strict; use warnings;
my $seq = 'xHxxHyyKzDt';
my @any = ( '(.+)', '(.+?)' );
my @vars = ('a'..'z'); my @keys = qw( H K D );
my $cmd;
my $index = 0; for my $key (@keys) { $cmd .= "for my \$$vars[$index++] (0..1) {\n"; } $cmd .= "for my \$$vars[$index++] (0..1) {\n";
$index = 0; $cmd .= "my \$any = '^' .\n"; for my $key (@keys) { $cmd .= "\$any[\$$vars[$index]] . '$keys[$index++]' .\n"; } $cmd .= "\$any[\$$vars[$index]] . '\$';\n";
$cmd .= "\$uniq{\""; $index = 0; for my $i ([EMAIL PROTECTED]) { $cmd .= "\$$i "; } chop $cmd; #remove the last space we added $cmd .= "\"}++ if \$seq =~ /\$any/;\n";
$index = 0; for ([EMAIL PROTECTED]) { $cmd .= "}\n"; }
#print $cmd; my %uniq; eval $cmd;
print join("\n", keys(%uniq)) . "\n";
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>