having some trouble with character substitution/regX

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a file that includes some directory paths and I want to use PERL
to change the file paths

I want to substitute this line of text:

.include '/doob/fred/bicmos/rev8/models/2010.11.07/hop/'

with this line of text:

.include 'D:/spi_models/TI/Hspice/'

and thought I would use the following code to do the job:

if (/include/)

but, the result is that the substitution does not occur.

Any ideas as to why, and how to fix it?



Re: having some trouble with character substitution/regX

Quoted text here. Click to load it

Note that '.' is special in regular expressions. If you want to match a
literal string, the safest way is to use \Q:


You haven't posted a complete program. If I create a file doob

    .include '/doob/fred/bicmos/rev8/models/2010.11.07/hop/'

and then run

    % perl -pe'if (/include/) {
    }' doob

I get the output

    .include 'D:/spi_models/Tee/Hspice/'

as expected, so there must be something wrong with your program
somewhere else.


For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt ] * ben@morrow.me.uk

Site Timeline