One more thing: Since we're talking about W2k, you can also use
$ENV{USERPROFILE} in place of C:\Documents and Settings\chrisz. Of course
that won't really help you in this case since you are interpolating it into
a regular expression, but it can be handy in the long run to know.
-----Original Message-----
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 20, 2002 6:01 PM
To: 'Chris Zampese'; [EMAIL PROTECTED]
Subject: RE: substitution
There are two things happening here.
1) You need to include the e switch at the end of your s/// expression.
Otherwise the second part of the substitution is taken literally.
2) When you use a variable as the first part of a regular expression,
it is interpolated first, and then the result is used for the comparison.
If your variable ends up evaluating to c:\Documents when it is
interpolated,
then the regular expression thinks you want c: followed by a non-digit
character
and then 'ocuments'.
See the script below as an example.
################################
use strict;
my $line = 'c:\Documents and Settings\chrisz\Desktop\Web_notes\HTTP';
my $rplcthis = 'c:\\\\Documents and
Settings\\\\chrisz\\\\Desktop\\\\Web_notes';
my $with = '..';
$line =~ s/$rplcthis/$with/ge;
print "\$line => $line\n";
print "\$rplcthis => $rplcthis\n";
print "\$with => $with\n";
################################
-----Original Message-----
From: Chris Zampese [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 20, 2002 5:43 PM
To: [EMAIL PROTECTED]
Subject: substitution
Hi everyon, thanks for your help so far....
I am trying to substitute a path for another path.
I have html documents which refer to some images in the following directory:
C:\Documents and Settings\chrisz\Desktop\Web_notes\PFLogo.gif
I would like to change this so it reads:
...../PFLogo.gif
I have tried the following substitution:
$rplcthis = "C:\\Documents and Settings\\chrisz\\Desktop\\Web_notes";
$with = "..";
$line =~ s/$rplcthis/$with/g;
But it does not seem to work. Through testing, I think that it is the '\'
character that it does not like in the regex?
Any help would be really great,
Thanks,
Chris.
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]