CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
The dollar issue in evaluated regexps

 



philgoodbike
New User

Oct 28, 2010, 8:41 AM

Post #1 of 1 (1541 views)
The dollar issue in evaluated regexps Can't Post

This is a problem I want to solve for long, and I've already tried hard to solve it. So I need an expert's help to find out how to deal with the "$" in an evaluated regexp.

In evaluated regexps the dollar is seen as a variable sign only, but not as a line end (with m modifier)
I want to keep the possibility to use $ for line end.

The code describes the issue (under linux) :
When $Text_find_str has no dollar, it works
with the dollar sign it doesn't



##############################
#!/usr/bin/perl -w

# This should remove the "ikos analyze_off" line from $text
# but the dollar sign is not correctly interpreted

my $text = "-- ikos analyze_off\n--pragma synthesis_off\n";
my $Text_typeRegExp = '=~';
my $Text_find_str = '^\s*--\s*ikos\s+analyze_o(ff|n).*$\n';
#my $Text_find_str = '^\s*--\s*ikos\s+analyze_o(ff|n).*\n';
my $Text_repl_str = '';
my $Text_modifier = 'm';


print "1> \$text = \[$text\]\n";
print "2> $Text_typeRegExp\n";
print "3> $Text_find_str\n";
print "4> $Text_repl_str\n";
print "5> $Text_modifier\n";

my $Text_RegExp = "s/$Text_find_str/$Text_repl_str/$Text_modifier";

print "6> \$text $Text_typeRegExp $Text_RegExp\n";
eval "\$text $Text_typeRegExp $Text_RegExp";

print "7> \$text = \[$text\]\n";
################################


Thx for your help

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives