
substituting string of text
Quote:
> Please forgive my Perl newbie-ness, but I need help with a line of
> code that causing me problems.
> I want to substitue one filename with another. I don't know how to
> work around the issue of forward slashes in the filename.
> I tried this:
> -----------CODE-----------------
> # convert one bullet graphic to another bullet graphic
> $t =~ s/"/images/static/gfx/bullet.gif"/"http://www.mywebsite.com/images/newbullet.gif"/>/gi;
> --------------------------------
> Attempts to run the script with this line of code didn't work. How can
> I identify the address of the graphics without the slashes, or a least
> making the script ignore the slashes in the filenames?
> Thanks to anyone who can help!
You shouldn't try so much without first trying to figure out what you're
doing. Just typing in random things is going to cause you problems.
$t =~
s!"/images/static/gfx/bullet\.gif"!"http://www.mywebsite.com/images/newbullet.gif"/>!gi;
If you start the substitution with /, you can only use is as
s/stuffhere/newstuffhere/ Otherwise you need to backwack it as in
s/some\/stuff\/here/some\/new\/stuff/\here/
Anyway, the above still doesn't look right, even if it fixes your error
in the code, but I don't want to guess.
Regards,
Robert
--
Server administrator/support - 2Host.com web hosting.
Secure, reliable hosting - What you expect & deserve!
How are we different? Find out: http://www.2host.com/