pppaulll has asked for the wisdom of the Perl Monks concerning the following question:
The parameter file (following) uses the first character to specify what operation (search or exception) the user wants to perform. The regexp runs from column 2 to the end of the line. What I want to do is use delimiters and modifiers included in the parameter file:/coWs/i
This works when delimiters are not included in the parameter file, but is very limited and flakey.+/six/i -/were/
Here is some of the code:+[Ss][Ii][Xx]
# Process Global Exceptions first foreach $except (@$glob_except) { $cexcept = substr($except, 1); $targf{$tkey} = "1:0" if ($tkey =~ /$cexcept/); # EXPANDS VARIABL +E HERE ### I would like the delimeters to be contained in the variable: ...( +$tkey =~ $cexcept); } elsif ($ttype eq '+') { if ($tkey =~ /$ttext/) { ; # EXPANDS VARIABLE HERE $targf{$tkey} = "3:$err_rtn"; $found = 1; } } elsif ($ttype eq '-' && substr($targf{$tkey},0,1) == 3) { if ($tkey =~ /$ttext/) {; # EXPANDS VARIABLE HERE $targf{$tkey} = "2:0"; $found = 0; } } else { ### ETCETERA ### THIS IS HOW THE HASH CONTAINING THE MATCH STRING IS LOADED elsif ($line_header eq '!') { ## Optional # Spec a global exception that affects all lines # interpolation takes place. unless ($trans_state == 2) {die "ERR: Global exception out of sequence";} push (@$glob_except, $line); # <= LOADING THE VARIABLE FROM + FILE # Trans state stays at 2 until set to 3 in subsequent logic
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do pack a regular expression in a variable?
by japhy (Canon) on Nov 29, 2001 at 21:45 UTC | |
|
Re: How do pack a regular expression in a variable?
by davorg (Chancellor) on Nov 29, 2001 at 22:37 UTC | |
|
Answer: How do pack a regular expression in a variable?
by Anonymous Monk on Nov 30, 2001 at 20:14 UTC |