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


in reply to simple regex question

You could try something like this:

#!/usr/bin/perl use strict; use warnings; $|++; use 5.010; my $before = 'foo'; my $after = 'stuff'; my $pattern = 'blablah'; my $combined = $before . $pattern . $after; my @test = qw( blahblahblah stuffstuffstuff fooblablahstuff fooblahblahstuff onefooblablahstuff ); match($_) for(@test); sub match { my $test = shift; say "$test matches" if( $test =~ /$combined/o ); }