http://www.perlmonks.org?node_id=576082


in reply to how to get the String as regularexpression

Have a look at the qr-operator

sample:
#!/usr/bin/perl use strict; use warnings; my $extensions = qr/\.doc|\.gif/; my @files = qw(test.doc test.gif test.png test.jpg); for(@files){ if($_ =~ $extensions){ print "yes\n"; } }