How about:
sub check_logs { my $regx_maker = shift(@_); my @clients = qw(abc def hij); foreach my $client (@clients) { my $regx = &$regx_maker($client); print($regx, "\n"); } } foreach my $regx_maker ( sub { my $client = shift; qr/pre-${client}-post/ }, sub { my $client = shift; qr/foo-${client}-bar/ }, ) { check_logs($regx_maker); } __END__ output ====== (?-xism:pre-abc-post) (?-xism:pre-def-post) (?-xism:pre-hij-post) (?-xism:foo-abc-bar) (?-xism:foo-def-bar) (?-xism:foo-hij-bar)
In reply to Re: dynamic regex variable
by ikegami
in thread dynamic regex variable
by lowone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |