sdetweil has asked for the wisdom of the Perl Monks concerning the following question:
but if the expression is really a command, replace for example, then it fails..$data = "this is a test" $expression_text = "(.*)es" $data =~ $expression_text $result = $1 which is 'this is a t';
$data = "this is a test" $expression_text = "s/es/dd/g" $data =~ $expression_text
a particular example is a file name string which was put into a file with single quotes, and on the commandline it needs to be double quotes..
'somefile.dat' = "somefile.dat", s// would do that fine..
but I can't seem to understand the nuance of getting perl to execute it properly..
using re debug,
it shows that the text in the right side variable is treated as the ENTIRE string to match against.
re eval doesn't help.
evl (var = var) doesn't do it.
oh sage ones, show me the light..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using just variables in a regular exression
by davido (Cardinal) on Aug 30, 2012 at 23:24 UTC | |
by sdetweil (Sexton) on Aug 31, 2012 at 00:38 UTC | |
by davido (Cardinal) on Aug 31, 2012 at 00:52 UTC | |
by sdetweil (Sexton) on Aug 31, 2012 at 02:19 UTC | |
by davido (Cardinal) on Aug 31, 2012 at 02:49 UTC | |
by sdetweil (Sexton) on Aug 31, 2012 at 03:31 UTC | |
|
Re: using just variables in a regular exression
by philiprbrenan (Monk) on Aug 30, 2012 at 22:55 UTC | |
|
Re: using just variables in a regular exression
by ww (Archbishop) on Aug 31, 2012 at 02:42 UTC | |
by sdetweil (Sexton) on Aug 31, 2012 at 03:18 UTC |