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:
Good.. I had expected that...
Code2..n:
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/;
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:
Code1:my $String="1234A4321"; my $RegEx="/a/i";
prints: Match: A Pre: 1234 Post: 4321{ $String=~/a/i; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; }
Good.. I had expected that...
Code2..n:
prints:{ $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"; }
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!,
- ChOas
print "profeth still\n" if /bird|devil/;
Back to
Seekers of Perl Wisdom