I was having some problems with the regular expression in the code down
below. Can anybody tell me why the replacement doesn't work. I've used
various modifiers, but nothing really helped.
-Socheavy
#!/usr/local/mysql/perl
use strict;
my %hash=();
# original string to be replaced
$hash{string} = "(617)
786-8999";
$hash{replacement} = $hash{string};
foreach my $key (keys %hash) {
$hash{$key} =~ s/\(/\\\(/igm;
$hash{$key} =~ s/\)/\\\)/igm;
$hash{$key} =~ s/\-/\\\-/igm;
}
$hash{replacement} =~ s/\n//igm;
$hash{replacement} =~ s/\r//igm;
$hash{replacement} =~ s/\t//igm;
# print out strings
print "STRING: $hash{string}\n";
print "REPLACEMENT: $hash{replacement}\n";
$hash{string} =~ s/$hash{string}/$hash{replacement}/igm; # do the
replacement
print "AFTER: $hash{string}\n"; # check to see if it worked
1;
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm