lowone has asked for the wisdom of the Perl Monks concerning the following question:
/usr/bin/perl -w use strict; my $client = 123; # default value my $regx = qr/$client/; check_logs($regx); sub check_logs { my $regx = shift(@_); my @clients = qw(abc, def, hij); foreach my $client (@clients) { print($regx, "\n"); } # I want the $regex to bind to the $clie +nt variable inside the sub. }
In my real world problem my regex has other literals
before and after the $client variable that I will be
passing to my subroutine. I'm trying to avoid having a
$pre_regex and post_regex surrounding my $client
variable that I would have to pass into my subroutine.
I want to write a general purpose routine to handle log
files with different namings standards.
Janitored by Arunbear - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dynamic regex variable
by ikegami (Patriarch) on Oct 02, 2004 at 02:45 UTC | |
by ikegami (Patriarch) on Oct 02, 2004 at 03:29 UTC | |
|
Re: dynamic regex variable
by TGI (Parson) on Oct 02, 2004 at 02:51 UTC | |
|
Re: dynamic regex variable
by educated_foo (Vicar) on Oct 02, 2004 at 03:20 UTC | |
by Anonymous Monk on Oct 02, 2004 at 09:01 UTC |