SPUG: Anyone savvy in this?
Chris Wilkes
cwilkes-spug at ladro.com
Wed Jan 30 12:31:09 CST 2002
On Wed, Jan 30, 2002 at 09:27:19AM -0800, Susanne Bullo wrote:
> I think I have it narrowed down but am still unclear as to what should be
> in:
>
> $row[4] =~ s/<br />/somethinghere/g;
>
> Basically, I want to look at that string in $row[4], find all instances of
> <br /> and replace it with line breaks.
Watch the slashes as you've started to tell perl to replace "<br " with
">" and with the switches of "somethinghere" -- maybe if you just used
the letters "imsxo" you could of made it through the interpreter ;)
Backslash the "/" like "\/" or use a different symbol for your
substitutes, like a #:
$row[4] =~ s/<br \/>/somethinghere/g; # with backslashes
$row[4] =~ s#<br />#somethinghere#g; # with #'s (easier to read)
Now I have a question about this, what if she said
$br = "< br />";
$row[4] =~ s/$br/somethinghere/g;
Why doesn't that blow up? Good thing I checked this, I thought it did
gives problems in previous versions of perl and was going to ask how to
get around it.
Chris
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list