in reply to RegEx Array
my $string = "Field1: one"; foreach my $reobj ( qr/Field1/, qr/Field2/, qr/Field3/) { print "$1\n" if $string =~ m/$reobj: (\w{3})/; }
Basically you can take advantage of the aliasing feature of foreach loops to help in creating your multiple re's. Another alternative would be simple alternation.
Update: To more specifically address your question, there's no reason why you couldn't put the regular expressions into an array like this:
my $string = "Field1: one"; my @regexobjs = ( qr/Field1/, qr/Field2/, qr/Field3/ ); foreach my $reobj ( @regexobjs ) { # The rest is the same as above.....
Dave
|
|---|