http://qs321.pair.com?node_id=103786

ChOas has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Celebates,

This should be simple, and I`m sure it CAN be done...Sad enough I`m also
sure that I haven`t been able to do it yet......

I want to apply a RegEx to a variable .. easy... BUT the RegEx resides
in a scalar...
Vars:
my $String="1234A4321"; my $RegEx="/a/i";
Code1:
{ $String=~/a/i; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; }
prints: Match: A Pre: 1234 Post: 4321
Good.. I had expected that...

Code2..n:
{ $String=~$RegEx; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; } { eval $String=~$RegEx; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none"," +\n"; } { eval { $String=~$RegEx; }; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none"," +\n"; }
prints:
Match: none Pre: none Post: none
Match: none Pre: none Post: none
Match: none Pre: none Post: none
Match: none Pre: none Post: none

This is frustrating.. I`m just looking for code X (be it in an eval, or not, I don`t care)
that prints Match: A Pre: 1234 Post: 4321, given $String and $RegEx....

Any help would be very much appreciated...

GreetZ!,

print "profeth still\n" if /bird|devil/;