i would like to do a pattern match where the thing to be matched is a
$VARIABLE, not a previously known value that could otherwise be simply
'hard-coded' into the regex (as most regex users do).  I need to do
something more dynamic than that.

so i assign the regex program line to a scalar, then eval the scalar.

on the surface, this should work. (and i can swear that in the very old days
with perl 4.036 on win95, it actually did).  but now that i run activeperl
5.8.8 build 822 on xp this ability seems not to work for me.  of course,
this could also be my mis understanding, or my mistake.  perhaps those with
more expertise than myself can take a quick look at my code.

here is simple code demonstrating what i am attempting to do:

 

$word      = 'word2';
$paragraph = 'word1 word2 word3';
$block = "\x24paragraph =~ \x2F$word\x2Fi;";

print "block to eval = $block\n";

eval { $block }; warn $@ if $@;

if ($') {
    print "what follows the match = $'\n";
} else {
    print "why wasnt '$word' found in '$paragraph'????\n";
}

running it displays clearly that 'word2' is not found within the string
containing 'word1 word2 word3'.

i dont understand why this simple example does not work.

your help would be GREATLY appreciated.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to