Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: same database problem

by Cody Pendant (Prior)
on Jul 04, 2003 at 01:17 UTC ( [id://271352]=note: print w/replies, xml ) Need Help??


in reply to same database problem

While we're here, sulferic, you might want to note that you can use other characters than / when doing "$x =~ s///" -- you can use # or ! or | and so on, which makes it a lot easier when replacing involves HTML. Also you seem to be under the impression that you need to escape HTML brackets and quotes with preceding slashes, but you don't. Your line:
$message =~ s/:\)/\<img src=\"$imagedir\/smiley.gif\"\>/g;
could just be
$message =~ s#:\)#<img src="$imagedir/smiley.gif">#g;
or
$message =~ s{:\)} {<img src="$imagedir/smiley.gif">}g;


“Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
M-J D

Replies are listed 'Best First'.
Re: Re: same database problem
by sulfericacid (Deacon) on Jul 04, 2003 at 03:01 UTC
    I wasn't aware you could use different characters during a substitution, thanks for that bit of info. You're right, that would make life a lot easier to read using # instead of slashes in situations like this. Your first solution is easy to read, I'll have to admit when using curlies confuses me.

    This problem was bugging me for a few weeks now so I was throwing in anything I thought the problem could be (escaping every non-letter character). Also, I make a habit of escaping pretty much everything because I don't quite understand when things need to be escaped and when they're ok.

    Thanks for the suggestion, that's really going to clean up my code :)

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://271352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found