SPUG:Help with substitution

Nord, Chris chris.nord at attws.com
Thu May 15 18:33:34 CDT 2003


I am having trouble with substitution when the variable $pattern
contains non-word characters. See example 1. Ideas on how to make
example 1 work like example 2?  I have tried a few variations when
creating $pattern, but so far have not got the substitution to work.

Thanx,

Chris Nord
AT&T Wireless Services
WNS Call Routing Translations
office 425 288 2031
fax     425 806 3690

###################################################

#! /bin/perl -w

$data = '(PREXLIDX 501) ( CARRMNC (TEST)$)$ $';
$pattern = '( CARRMNC (TEST)$)';

## example 1
($new_data = $data) =~ s/$pattern/something new/;
print $new_data,"\n";

# output: (PREXLIDX 501) ( CARRMNC (TEST)$)$ $


## example 2
($new_data = $data) =~ s/\( CARRMNC \(TEST\)\$\)/something new /;
print $new_data,"\n";

# output: (PREXLIDX 501) something new $ $

###################################################



More information about the spug-list mailing list