Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Questions

by Chady (Priest)
on Nov 10, 2003 at 14:42 UTC ( #305877=note: print w/replies, xml ) Need Help??

in reply to <FILE> Questions

There's a lot of wierd stuff going on in here, I'm not sure I got this right, but let's try.

In your second example, you use $_content where I see a $content read from the db. then you perform your substitution on $_ where you should have done it -- I assume -- on $content, $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval ($1) /ge;

OTOH, I think it's safer/better(?) to use a hash instead of evaluating strings. So instead of doing s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval ($1) /ge; you would do s/{{([a-zA-Z0-9\{\'\}_]+)}}/$hash{$1}/g; - but I don't know the context of this, so I can't judge.

does this actually run? what errors does it produce?

Update: I re-read your question, namely this part:

What if that is in a database, and instead of it having $string it has {{string}} and I normally do a s/{{string}}/$string/g;
That would work if you do it like so:
unless you're using strict refs.

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady |

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305877]
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2017-02-21 15:00 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (313 votes). Check out past polls.